https://github.com/lucid-services/serviser-rabbitmq
The plugin which integrates AMQP 0.9.1 with `serviser`
https://github.com/lucid-services/serviser-rabbitmq
amqp0-9-1 microservice
Last synced: about 2 months ago
JSON representation
The plugin which integrates AMQP 0.9.1 with `serviser`
- Host: GitHub
- URL: https://github.com/lucid-services/serviser-rabbitmq
- Owner: lucid-services
- License: gpl-3.0
- Created: 2019-02-07T09:05:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T18:01:37.000Z (about 6 years ago)
- Last Synced: 2025-02-14T22:24:02.823Z (4 months ago)
- Topics: amqp0-9-1, microservice
- Language: JavaScript
- Homepage:
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/lucid-services/serviser-rabbitmq)
Implementation of serviser'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](https://github.com/lucid-services/serviser-rabbit) [rabbit.js](https://github.com/squaremo/rabbit.js) library under the hood.### Usage
Load the plugin at the bottom of your `index.js` file:
```javascript
require('serviser-rabbitmq'); //loads the plugin
```Initialize a message queue App in your app.js file:
```javascript
service.buildMQApp('your-app-name-in-config.json5');
```#### Example of `SUBSCRIBE` endpoint definition of `PUBLISH & SUBSCRIBE` pattern:
```javascript
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:
```javascript
//serviser based project...
const rabbit = require('serviser-rabbit');
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::v1.0', {socket: amqp});
const socket = sdk.get('email-updated');socket.write('[email protected]');
```See [client SDKs integration](https://lucid-services.github.io/serviser/tutorial-4.SDK-integration.html)
#### Route `type`s
as described under [socket types](http://www.squaremobius.net/rabbit.js/) section of `rabbit.js` documentation.
### Tests
```bash
> export AMQP_URI='amqp://username:password@localhost:5672/vhost'
> npm test
```