Hapi plugin version of Rascal, a config driven wrapper around amqplib

Usage no npm install needed!

<script type="module">
  import hapiRascal from 'https://cdn.skypack.dev/hapi-rascal';


Hapi plugin version of Rascal, a config driven wrapper around amqplib


npm install hapi-rascal --save


With a Rascal config, read more

let options = {
    'vhosts': {
        '/': {

            'connection': {
                hostname: 'localhost',
                port: 5672,
                user: process.env.WETOPI_RABBITMQ_DEFAULT_USER || 'guest',
                password: process.env.WETOPI_RABBITMQ_DEFAULT_PASS || 'guest'

            'exchanges': {
                testEx: {
                    type: 'topic',
                    options: {
                        durable: true

            'queues': {
                test: {
                    options: {
                        durable: true,
                        exclusive: false

            'bindings': [
                'testEx[a.test.#] -> test'

            'publications': {
                foo: {
                    exchange: 'testEx',
                    routingKey: 'a.test.foo'
                bar: {
                    exchange: 'testEx',
                    routingKey: 'a.test.bar'


            'subscriptions': {
                test: {
                    queue: 'test',
                    contentType: 'application/json'


Plus the option to add a driver:

let options = {
    'vhosts': {...},
    'drivers': [{
        module: 'hapi-message-manager',
        name: 'events',
        options: {
            publication: 'dom.obj.act.det'

e.g. hapi-message-manager

Register the hapi-rascal plugin

server.register({ register: 'hapi-rascal', options: options });

Consume the service:

Once registered you get a broker object you can consume:

// publish:
server.plugins.rascal.broker.publish('foo', { 'my': 'message to foo'});
server.plugins.rascal.broker.publish('bar', { 'my': 'message to bar'});

// subscribe:
server.plugins.rascal.broker.subscribe('test', function(err, subscription) {
    subscription.on('message', function(message, content, ackOrNack) {

        console.log('[*] Consumed message from test queue. content:', content);

    }).on('error', function(err) {
        console.error('Subscriber error', err);

    }).on('invalid_content', function(err, message, ackOrNack) {
        console.error('Invalid content', err);
}).on('error', console.error);

Consume the service through a driver:

Following the driver in the example. The sample driver publish method gets exposed as:

server.plugins.rascal.broker.publish({ message }, 'domain-a.message.event.sample-event');

Running the tests

Bebore running test, check test connection section.

npm test

You'll need a RabbitMQ server running locally with default configuration. If that's too much trouble try installing docker and running the following

docker run -d -p 5672:5672 -p 15672:15672 rabbitmq