All Projects → KristjanTammekivi → Haredo

KristjanTammekivi / Haredo

Licence: MIT license
Node.js library for RabbitMQ

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Haredo

opentelemetry-ext-js
js extensions for the open-telemetry project
Stars: ✭ 122 (+60.53%)
Mutual labels:  rabbitmq, amqp0-9-1
amq-protocol
AMQP 0.9.1 protocol serialization and deserialization implementation for Ruby (2.0+)
Stars: ✭ 47 (-38.16%)
Mutual labels:  rabbitmq, amqp0-9-1
BUA-FE
本科毕设,搭建一套小而全面的校园外卖系统。主要使用wei-xin-mini + TypeScript + nest.js + typeORM + rabbitmq技术栈。
Stars: ✭ 20 (-73.68%)
Mutual labels:  rabbitmq, amqplib
Pika
Pure Python RabbitMQ/AMQP 0-9-1 client library
Stars: ✭ 2,866 (+3671.05%)
Mutual labels:  rabbitmq, amqp0-9-1
nabbitmq
Node.js library for interacting with RabbitMQ based on RxJS streams
Stars: ✭ 20 (-73.68%)
Mutual labels:  rabbitmq, amqp0-9-1
nest-rabbit-tasks
nest-rabbit-worker is a TaskQueue based upon RabbitMQ for NestJS
Stars: ✭ 29 (-61.84%)
Mutual labels:  rabbitmq, amqp0-9-1
Spring-Boot-2
Spring Boot 2.x examples
Stars: ✭ 33 (-56.58%)
Mutual labels:  rabbitmq
longears
The RabbitMQ client for R
Stars: ✭ 32 (-57.89%)
Mutual labels:  rabbitmq
robert
基于SpringCloud的企业级微服务多租户系统、多语言的脚手架, 代码组件化、高内聚低耦合,代码简介,注释丰富容易上手,该项目包括用于开发分布式应用程序服务的必要组件,支持多应用程序访问,并使开发人员可以轻松地使用Spring Cloud编程模型来开发分布式应用程序服务。
Stars: ✭ 45 (-40.79%)
Mutual labels:  rabbitmq
event-driven-example
An example Event-Driven application in Go built with Watermill library.
Stars: ✭ 81 (+6.58%)
Mutual labels:  rabbitmq
TelephoneDirectory
microservices-> .net 6, golang - Docker, Ocelot, RabbitMq, MassTransit, mssql, postgresql, elasticsearch, kibana, jwt
Stars: ✭ 40 (-47.37%)
Mutual labels:  rabbitmq
slackotron
A plugin extensible Slack bot.
Stars: ✭ 13 (-82.89%)
Mutual labels:  rabbitmq
distmq
Distributed Message Queue based on Raft
Stars: ✭ 32 (-57.89%)
Mutual labels:  rabbitmq
leek
Celery Tasks Monitoring Tool
Stars: ✭ 77 (+1.32%)
Mutual labels:  rabbitmq
docker-case
这个项目主要是为了快速拉起docker服务
Stars: ✭ 31 (-59.21%)
Mutual labels:  rabbitmq
fluent-plugin-rabbitmq
Fluent input/output plugin for RabbitMQ.
Stars: ✭ 26 (-65.79%)
Mutual labels:  rabbitmq
nestjs-rmq
A custom library for NestJS microservice. It allows you to use RabbitMQ or AMQP.
Stars: ✭ 182 (+139.47%)
Mutual labels:  rabbitmq
gome
gome- Golang Match Engine, uses Golang for calculations, gRPC for services, ProtoBuf for data exchange, RabbitMQ for queues, and Redis for cache implementation of high-performance matching engine microservices/ gome-高性能撮合引擎微服务
Stars: ✭ 47 (-38.16%)
Mutual labels:  rabbitmq
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+123.68%)
Mutual labels:  rabbitmq
broadway bike sharing rabbitmq example
An example of a Broadway pipeline for a bike sharing app with RabbitMQ and PostgreSQL
Stars: ✭ 27 (-64.47%)
Mutual labels:  rabbitmq

Haredo

Haredo version 2 introduces breaking changes. See 2.0 Changes

npm npm Build Status Coverage Status Libraries.io dependency status for latest release

haredo

Yet another RabbitMQ library

Motivation

xkcd 927: standards

xkcd 927: standards

For a long time I've been using tortoise as my go-to RabbitMQ client. I quite like the chaining API it has but tortoise does have it's downsides (it's not being maintained, accessing message metadata needs you to not use arrow functions, missing typings, etc.)

Features

  • TypeScript
  • Chaining based API
  • Graceful closing
  • RPC

Usage

Working examples are available on github

Initializing

import { haredo } from 'haredo';
const rabbit = haredo({
    connection: 'amqp://localhost:5672/'
});

Listening for messages

example on GitHub

rabbit.queue('my-queue')
    .bindExchange('testExchange', '#', 'topic', { durable: false }) // Can be omitted if you don't want to bind the queue to an exchange right now
    .consume(async (message) => {
        console.log(message);
    });

Publishing to an exchange

example on GitHub

rabbit.exchange('my-exchange').publish({ id: 5, status: 'active' }, 'item.created');

Publishing to a queue

example on GitHub

rabbit.queue('my-queue').publish({ id: 5, status: 'inactive' });

Limit concurrency

rabbit.queue('my-queue')
    .prefetch(5) // same as .concurrency(5)
    .consume(async (message) => {
        console.log(message);
    });

RPC

example on GitHub

rabbit.queue('sum')
    // With autoReply on, returned value from callback is automatically replied
    // Alternative is to use the reply/1 method on the message
    .autoReply()
    .subscribe(({ data }) => data[0] + data[1]);

const response = await rabbit.queue('sum').rpc([30, 12])

Delayed messages

Note: this requires RabbitMQ Delayed Message Plugin to be installed and enabled on the server.

example on GitHub

interface Message {
    id: number;
}
const delayedExchange = e<Message>('my-delayed-exchange', 'x-delayed-message').delayed('topic');
await rabbit.queue('my-queue')
    .bindExchange(delayedExchange, '#')
    .subscribe(({ data, timestamp }) => {
        console.log(`Received message in ${ Date.now() - timestamp }ms id:${ data.id } `);
    });
const delayedMessage = preparedMessage().routingKey('item').delay(2000);
let id = 0;
while (true) {
    id += 1;
    console.log('Publishing message', id);
    const msg = delayedMessage.json({ id }).timestamp(Date.now());
    await rabbit
        .exchange(delayedExchange)
        .publish(msg);
    await delay(2000);
}

Quorum queues with delivery limits

Node: requires RabbitMQ 3.8.0 or higher, see Quorum Queues Overview for more information.

example on GitHub

Message throttling

example on GitHub

await rabbit.queue('my-queue')
    .backoff(standardBackoff({
        failThreshold: 3,
        failSpan: 5000,
        failTimeout: 5000
    }))
    .subscribe(() => {
        throw new Error('Nack this message for me')
    });

Dead letter

View on GitHub

Middleware

example on GitHub

import { Middleware } from 'haredo';

const timeMessage: Middleware = ({ queue }, next) => {
    const start = Date.now();
    await next();
    console.log(`Message took ${ Date.now() - start }ms`);
}

await rabbit.queue('my-queue')
    .use(timeMessage)
    .subscribe(() => {
        throw new Error('Nack this message for me')
    });

Graceful shutdown

Calling consumer.close() will send cancel to channel and wait for existing messages to be handled before resolving the returned promise.

Calling haredoInstance.close() will gracefully close all of it's consumers

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].