rabbitmq-rpc-client

v1.0.1
AMQP (RabbitMQ) Controller for RPC Client. Asynchronous handling of response using RxJS
AMQP RabbitMQ Controller RPC

amqp-rpc-client-controller

A client controller for sending asynchronous RPC requests over AMQP and RabbitMQ.

This client makes use of RxJs Observables for connection and response events.

Connecting Without Subscriptions

// Require Client Module
var RPC = require('rpc-client');

// Configure Client to Connect to RabbitMQ Server

var config = RPC.Config({
    username: 'user',
    password: 'password',
    host: 'example.com',
    vhost: 'vhost'
});

// Start Client
var client = RPC.Client(config);

// Attempt to connect to server
client.connect();

Connecting With a Subscription

// Require Client Module
var RPC = require('rpc-client');

// Configure Client to Connect to RabbitMQ Server
var config = RPC.Config({
    username: 'user',
    password: 'password',
    host: 'example.com',
    vhost: 'vhost'
});

// Start Client
var client = RPC.Client(config);

// Attempt to connect to server
client.connect().subscribe(
    (channel) => { ... }, // Actions after connection is made
    (err) => { ... } // Handle Error
)

Sending a RPC Example

// Constant for the name of queue the RPC server is a member of
var QUEUENAME = 'api_queue';

// example object RPC server may be looking for
var message = {join: 'NewUsers'} 

// Send RPC to server and wait for a response to handle
client.rpcPush(QUEUENAME, message).subscribe(
    (res) => { console.log(res) },
    (err) => { console.error(err) }
);
npm i rabbitmq-rpc-client

Metadata

  • MIT
  • Whatever
  • Don Burgess
  • released 7/26/2016

Downloads

Maintainers