All Projects → mateodelnorte → Servicebus

mateodelnorte / Servicebus

Licence: mit
Simple service bus for sending events between processes using amqp.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Servicebus

Enqueue Dev
Message Queue, Job Queue, Broadcasting, WebSockets packages for PHP, Symfony, Laravel, Magento. DEVELOPMENT REPOSITORY - provided by Forma-Pro
Stars: ✭ 1,977 (+376.39%)
Mutual labels:  rabbitmq, amqp, message-bus
Benthos
Fancy stream processing made operationally mundane
Stars: ✭ 3,705 (+792.77%)
Mutual labels:  rabbitmq, amqp, message-bus
Enqueue Bundle
[READ-ONLY] Message queue bundle for Symfony. RabbitMQ, Amazon SQS, Redis, Service bus, Async events, RPC over MQ and a lot more
Stars: ✭ 233 (-43.86%)
Mutual labels:  rabbitmq, amqp, message-bus
Humusamqp
PHP 7 AMQP library
Stars: ✭ 70 (-83.13%)
Mutual labels:  rabbitmq, messaging, amqp
psr-container-messenger
Message bus and queue for Mezzio with Symfony Messenger + Enqueue
Stars: ✭ 24 (-94.22%)
Mutual labels:  messaging, bus, message-bus
Bunny
Bunny is a popular, easy to use, mature Ruby client for RabbitMQ
Stars: ✭ 1,224 (+194.94%)
Mutual labels:  rabbitmq, messaging, amqp
Rebus
🚌 Simple and lean service bus implementation for .NET
Stars: ✭ 1,733 (+317.59%)
Mutual labels:  service-bus, messaging, message-bus
Azure Service Bus
☁️ Azure Service Bus service issue tracking and samples
Stars: ✭ 472 (+13.73%)
Mutual labels:  service-bus, messaging, amqp
azure-service-bus-java
☁️ Java client library for Azure Service Bus
Stars: ✭ 61 (-85.3%)
Mutual labels:  amqp, messaging, service-bus
Slimmessagebus
Lightweight message bus interface for .NET (pub/sub and request-response) with transport plugins for popular message brokers.
Stars: ✭ 120 (-71.08%)
Mutual labels:  bus, messaging, message-bus
Rabbitmq Server
Open source RabbitMQ: core server and tier 1 (built-in) plugins
Stars: ✭ 9,064 (+2084.1%)
Mutual labels:  rabbitmq, messaging, amqp
azure-service-bus-dotnet-plugins
☁️ Plugins for the .NET Standard client library for Azure Service Bus
Stars: ✭ 15 (-96.39%)
Mutual labels:  amqp, messaging, service-bus
Rabbitmqbundle
RabbitMQ Bundle for the Symfony2 web framework
Stars: ✭ 1,125 (+171.08%)
Mutual labels:  rabbitmq, messaging, amqp
Garagemq
AMQP message broker implemented with golang
Stars: ✭ 153 (-63.13%)
Mutual labels:  rabbitmq, messaging, amqp
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-94.22%)
Mutual labels:  rabbitmq, messaging, amqp
Azure Service Bus Dotnet
☁️ .NET Standard client library for Azure Service Bus
Stars: ✭ 237 (-42.89%)
Mutual labels:  service-bus, messaging, amqp
godsend
A simple and eloquent workflow for streaming messages to micro-services.
Stars: ✭ 15 (-96.39%)
Mutual labels:  messaging, bus, message-bus
Php Amqplib
The most widely used PHP client for RabbitMQ
Stars: ✭ 3,950 (+851.81%)
Mutual labels:  rabbitmq, messaging, amqp
OpenSleigh
OpenSleigh is a Saga management library for .NET Core.
Stars: ✭ 198 (-52.29%)
Mutual labels:  rabbitmq, message-bus
AspNetCore.Weixin
An ASP.NET Core middleware for Wechat/Weixin message handling and apis. (微信公众平台/接口调用服务)
Stars: ✭ 24 (-94.22%)
Mutual labels:  middleware, messaging

Build Status

servicebus

Simple service bus for sending events between processes using amqp. Allows for send/receive and publish/subscribe pattern messaging over RabbitMQ.

Configuration

Sending and Receiving

Servicebus allows simple sending and recieving of messages in a 1:1 sender:listener configuration. The following two processes will send an event message called 'my.event' every second from process A to process B via RabbitMQ and print out the sent event:

Process A:

var bus = require('servicebus').bus();
bus.listen('my.event', function (event) {
  console.log(event);
});

Process B:

var bus = require('servicebus').bus();

setInterval(function () {
  bus.send('my.event', { my: 'event' });
}, 1000);

Round-Robin Load Distribution

Simply running multiple versions of Process A, above, will cause servicebus to distribute sent messages evenly accross the list of listeners, in a round-robin pattern.

Message Acknowledgement

(Note: message acking requires use of the https://github.com/mateodelnorte/servicebus-retry middleware)

Servicebus integrates with RabbitMQ's message acknowledement functionality, which causes messages to queue instead of sending until the listening processes marks any previously received message as acknowledged or rejected. Messages can be acknowledged or rejected with the following syntax. To use ack and reject, it must be specified when defining the listening function:

bus.listen('my.event', { ack: true }, function (event) {
  event.handle.acknowledge(); // acknowledge a message
  event.handle.ack(); // short hand is also available
  event.handle.reject(); // reject a message
});

Message acknowledgement is suited for use in load distribution scenarios.

Authentication (RabbitMQ Bus)

Fully qualified url

You may authenticate by providing url as an option when initializing the bus, or setting RABBITMQ_URL as an environment variable. RabbitMQ uses basic auth url format for authentication.

var bus = servicebus.bus({
  url: "amqp://user:[email protected]:5672,
})

config options

Alternatively, you may provide a user, password, host (optional, default = 'localhost'), and port (optional, default = 5672), and servicebus will construct the url before passing it to RabbitMQ.

var bus = servicebus.bus({
  user: 'rabbitUser',
  password: 'test1234',
  host: '1.1.1.1'
  port: '5555'
})

NOTE: If url and user/password are provided, the url will be used.

Publish / Subscribe

Servicebus can also send messages from 1:N processes in a fan-out architecture. In this pattern, one sender publishes a message and any number of subscribers can receive. The pattern for usage looks very similar to send/listen:

Process A (can be run any number of times, all will receive the event):

var bus = require('servicebus').bus();
bus.subscribe('my.event', function (event) {
  console.log(event);
});

Process B:

var bus = require('servicebus').bus();

setInterval(function () {
  bus.publish('my.event', { my: 'event' });
}, 1000);

Topic Routing

To use topic routing to accept multiple events in a single handler, use publish and subscribe and the following syntax:

bus.publish('event.one', { event: 'one' });
bus.publish('event.two', { event: 'two' });

and for the listener...

bus.subscribe('event.*', function (msg) ...

Middleware

Servicebus allows for middleware packages to enact behavior at the time a message is sent or received. They are very similar to connect middleware in their usage:

  if ( ! process.env.RABBITMQ_URL)
    throw new Error('Tests require a RABBITMQ_URL environment variable to be set, pointing to the RabbiqMQ instance you wish to use.');

  var busUrl = process.env.RABBITMQ_URL

  var bus = require('../').bus({ url: busUrl });

  bus.use(bus.package());
  bus.use(bus.correlate());
  bus.use(bus.logger());

  module.exports.bus = bus;

Middleware may define one or two functions to modify incoming or outgoing messages:

...

  function logIncoming (queueName, message, options, next) {
    log('received ' + util.inspect(message));
    next(null, queueName, message, options);
  }

  function logOutgoing (queueName, message, options, next) {    
    log('sending ' + util.inspect(message));
    next(null, queueName, message, options);
  }

  return {
    handleIncoming: logIncoming,
    handleOutgoing: logOutgoing
  };

handleIncoming pipelines behavior to be enacted on an incoming message. handleOutgoing pipelines behavior to be enacted on an outgoing message. To say that the behavior is pipelined is to say that each middleware is called in succession, allowing each to enact its behavior before the next. (in from protocol->servicebus->middleware 1->middleware 2->servicebus->user code)

Included Middleware

Correlate

Correlate simply adds a .cid (Correlation Identity) property to any outgoing message that doesn't already have one. This is useful for following messages in logs across services.

Logger

Logger ensures that incoming and outgoing messages are logged to stdout via the debug module. (Use this in non-high throughput scenarios, otherwise you'll have some very quickly growing logs)

Package

Package repackages outgoing messages, encapsulating the original message as a .data property and adding additional properties for information like message type and datetime sent:

  // bus.publish('my:event', { my: 'event' });
  {
    my: 'event'
  };

becomes

  {
    data: {
      my: 'event'
    }
    , datetime: 'Wed, 04 Sep 2013 19:31:11 GMT'
    , type: 'my:event'
  };

Retry

https://github.com/mateodelnorte/servicebus-retry

Retry provides ability to specify a max number of times an erroring message will be retried before being placed on an error queue. The retry middleware requires the correlate middleware.

Contributing

servicebus uses semantic-release for deploys.

Commits must follow Conventional Changelog to accurately calculate new versions.

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].