Skip to content

Instantly share code, notes, and snippets.

@geggleto
Created June 22, 2020 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geggleto/29614279acee4912a7d9bdf26cd1a7ec to your computer and use it in GitHub Desktop.
Save geggleto/29614279acee4912a7d9bdf26cd1a7ec to your computer and use it in GitHub Desktop.
var bus = servicebus.bus({
url: "amqp://user:pass@localhost:5672, //RabbitMQ or any other AMQP supporting service
})
//Export the bus so that somewhere else can listen
//In component A - This can be on a different physica/virtual server
bus.subscribe('my.event', function (event) {
bus.publish('my.event.conclusion', { something: 'happened' });
});
//In component B - This can be on a different physica/virtual server
bus.subscribe('my.event.conclusion', function (event) {
});
//In component C - This can be on a different physica/virtual server
//Maybe I care about all of these types of events
bus.subscribe('my.*', function (event) {
//Log or do something
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment