Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

The plugin which integrates AMQP 0.9.1 with bi-service

License

Notifications You must be signed in to change notification settings

BohemiaInteractive/bi-service-rabbitmq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Implementation of bi-service's AppInterface which allows to define receiving endpoints of AMQP 0.9.1 in the same manner http(s) routes would be defined.
Uses forked rabbit.js library under the hood.

Usage

Load the plugin at the bottom of your index.js file:

require('bi-service-rabbitmq'); //loads the plugin

Initialize a message queue App in your app.js file:

service.buildMQApp('your-app-name-in-config.json5');

Example of SUBSCRIBE endpoint definition of PUBLISH & SUBSCRIBE pattern:

const router = service.appManager
    .get('your-app-name-in-config.json5')
    .buildRouter({
        version: 1,
        url: '.'
    });

router.buildRoute({
    url: 'email-updated',
    type: 'subscribe', // one of: subscribe|pull|reply|worker
    summary: 'Sync user email',
    amqp: {/*amqp specific options*/},
    sdkMethodName: 'email-updated'
}).main(function(req) {
    return User.update({email: req.body.email});
});

PUBLISH data on client side:

//bi-service based project...
const rabbit           = require('bi-rabbitmq');
const remoteServiceMgr = service.getRemoteServiceManager();
const resourceManager  = service.resourceManager;

const amqp = rabbit.createConnection('amqp://username:password@localhost:5672/vhost');

resourceManager.register('amqp', amqp);

const sdk = remoteServiceMgr.buildRemoteService('user:<your-app-name>:v1.0', {socket: amqp});
const socket = sdk.get('email-updated');

socket.write('new@email.com');

See client SDKs integration

Route types

as described under socket types section of rabbit.js documentation.

Tests

> export AMQP_URI='amqp://username:password@localhost:5672/vhost'
> npm test

About

The plugin which integrates AMQP 0.9.1 with bi-service

Resources

License

Stars

Watchers

Forks

Packages

No packages published