3.0.0 • Published 7 years ago

hemera-rabbitmq v3.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Hemera-rabbitmq

Build Status npm styled with prettier

This is a plugin to use RabbitMQ with Hemera.

RabbitMQ is a messaging broker - an intermediary for messaging. It gives your applications a common platform to send and receive messages, and your messages a safe place to live until received. It is complementary to the primary NATS transport system.

The client use JSON to transfer data.

Start RabbitMQ instance

Start a rabbitmq instance via docker-compose

docker-compose up

Administration

Visit http://127.0.0.1:15672 and log in with

Username: user
Password: user

Example

const Hemera = require('nats-hemera')
const nats = require('nats').connect()
const hemera = new Hemera(nats, {
  logLevel: 'info'
})
hemera.use(require('hemera-joi'))
// Topology & configuration via JSON look at https://github.com/arobson/rabbot
hemera.use(require('hemera-rabbitmq', { rabbot: options }))

Plugin dependencies

  • hemera-joi

Interface


publish

The pattern is:

  • topic: is the service name to publish to rabbitmq
  • cmd: is the command to execute publish
  • exchange: the name of the exachange string
  • options: rabbot transport options object
  • data: the data to transfer object

Example:

hemera.act(
  {
    topic: 'rabbitmq',
    cmd: 'publish',
    exchange: 'pubsub',
    options: {
      type: 'MyMessage'
    },
    data: {
      name: 'peter',
      amount: 50
    }
  },
  function() {}
)

request

The pattern is:

  • topic: is the service name to publish to rabbitmq
  • cmd: is the command to execute publish
  • exchange: the name of the exachange string
  • options: rabbot transport options object
  • data: the data to transfer object

Example:

hemera.act(
  {
    topic: 'rabbitmq',
    cmd: 'request',
    exchange: 'request',
    options: {
      type: 'MyRequest'
    },
    data: {
      name: 'peter',
      amount: 50
    }
  },
  function() {}
)

Create pub/sub subscriber

Create a new rabbitmq subscriber which handles the interest on this subject and forward all message with pub/sub semantic to the hemera service.

The interface is:

  • pattern: the pattern which arrive hemera
  • type: the type string

Example:

hemera.rabbitmq.addPubSubProxy(
  {
    type: 'MyMessage'
    pattern: {}
  }
)

Create request/reply subscriber

Create a new rabbitmq subscriber which handles the interest on this subject and forward all message with request/reply semantic to the hemera service.

The interface is:

  • pattern: the pattern which arrive hemera
  • type: the type string

Example:

hemera.rabbitmq.addRequestProxy(
  {
    type: 'MyMessage'
    pattern: {}
  }
)

Consume events

The pattern is:

  • topic: is a combination of the serviec name and the type rabbitmq.<type>

Example:

hemera.add(
  {
    topic: 'rabbitmq.MyMessage'
  },
  function(req, reply) {
    // In case of pub / sub you can't reply
    // In case of request / reply you can reply only with valid json
  }
)
3.0.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.39

8 years ago

0.0.38

8 years ago

0.0.37

8 years ago

0.0.36

8 years ago

0.0.35

8 years ago

0.0.34

8 years ago

0.0.33

8 years ago

0.0.32

8 years ago

0.0.31

8 years ago

0.0.30

8 years ago

0.0.29

8 years ago

0.0.28

8 years ago

0.0.27

8 years ago

0.0.26

8 years ago

0.0.25

8 years ago

0.0.24

8 years ago

0.0.23

8 years ago

0.0.22

8 years ago

0.0.21

8 years ago

0.0.20

8 years ago

0.0.19

8 years ago

0.0.18

8 years ago

0.0.17

8 years ago

0.0.16

8 years ago

0.0.15

8 years ago

0.0.14

8 years ago

0.0.13

8 years ago

0.0.12

8 years ago

0.0.11

8 years ago

0.0.10

8 years ago

0.0.9

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago