rabbit.js icon indicating copy to clipboard operation
rabbit.js copied to clipboard

How to make a durable named queue?

Open Icehunter opened this issue 8 years ago • 0 comments

The reason I ask this is because I want to save the messages on a EBS volume so if the container running rabbitmq crashes I can at least connect to the EBS and bring the images back in.

I've used my own library for awhile which handles reconnects and persistence, but I would rather just use yours.

I've tried for the life of me to do something along the lines of direct routing, with routing keys.

Is there an example of working with ack(false/true, [true]) and direct/topic based push/worker?

Something along the lines of:

var context = require('rabbit.js').createContext();
context.on('ready', function () {
    var pub = context.socket('PUB', {
        routing: 'topic'
    });
    pub.connect('events', function () {
        pub.publish('events:create', {
            some: 'value'
        });
        pub.publish('events:try', {
            some: {
                new: 'value'
            }
        });
    });

    var sub = context.socket('SUB', {
        routing: 'topic'
    });
    sub.connect('events', 'events:create', function () {
        sub.on('data', function (item) {
            // item.ack [function]
            // item.message [json]
        });
    });

    var sub2 = context.socket('SUB', {
        routing: 'topic'
    });
    sub2.connect('events', 'events:try', function () {
        sub2.on('data', function (item) {
            // item.ack [function]
            // item.message [json]
        });
    });
});

I know this example won't work like this as you have to stringify the data first, then parse it for some reason. Maybe I'm missing something in the docs however. Any help would be appreciated :)

Icehunter avatar Aug 06 '15 03:08 Icehunter