Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

messagehub

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

messagehub

Simple message, queue and pubsub system compatible with RabbitMQ

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

messagehub

Simple message, queue and pubsub system compatible with RabbitMQ.

Communicates events and jobs across processes and servers.

Installation

npm install messagehub

You also need to connect to a running RabbitMQ server at the host specified.

Documentation

Create

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'

You can also send an AMQP url as the first parameter, or the options hash as describe here.

Events

Emit an event

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'
myhub.emit 'messages.one', {key: "value"}

Observe an event (ALL handlers will trigger)

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'
myhub.on 'messages.one', (data) ->
  console.log "MESSAGES.ONE", data

Jobs

Queue a job

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'
myhub.job 'jobs.one', {key: "value"}

Handle a job (jobs are balanced between workers)

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'
myhub.worker 'jobs.one', (data, done) ->
  console.log "JOBS.ONE", data
  done()

You can put more than one worker in the same file. It will only send you one job per worker registered.

messagehub = require 'messagehub'
myhub = messagehub 'localhost', 'mychannel'

# handler function
handleJobOne = (data, done) ->
  console.log "JOBS.ONE", data
  done()

# register 4 workers
myhub.worker 'jobs.one', handleJobOne
myhub.worker 'jobs.one', handleJobOne
myhub.worker 'jobs.one', handleJobOne
myhub.worker 'jobs.one', handleJobOne

Keywords

FAQs

Package last updated on 26 Sep 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc