rx-amqplib is a wrapper for using the squaremo amqplib NodeJS package with RxJS.
To include this library in your project, all you need to do is install it using NPM.
$ npm install rx-amqplib --save
Here is a basic example of creating a connection to a RabbitMQ server, creating a channel + queue and sneding a message to the queue.
const config = {
queue: 'test_queue',
host: 'amqp://localhost'
};
// Process stream
RxAmqpLib.newConnection(config.host)
.flatMap(connection => connection
.createChannel()
.flatMap(channel => channel.assertQueue(config.queue, { durable: false }))
.doOnNext(reply => reply.channel.sendToQueue(config.queue, new Buffer('Test message')))
.flatMap(reply => reply.channel.close())
.flatMap(() => connection.close())
)
.subscribe(() => console.log('Message sent'));
-
The simplest thing that does something.
-
Distributing tasks among workers
-
Sending messages to many consumers at once
-
Receiving messages selectively
-
Receiving messages based on a pattern
-
Remote procedure call implementation
Should you wish to build the library yourself, either for personal use, or for contribution, please ensure there are no errors emitted during the build process with npm run build
.
$ git clone [email protected]:SkippyZA/rx-amqplib.git
$ cd rx-amqplib
$ npm install
$ npm run build