1 | var AMQPHutch = require('../');
|
2 |
|
3 | var hutch = new AMQPHutch();
|
4 |
|
5 | console.log("Hutch Status:" + hutch.status);
|
6 |
|
7 | hutch.initialise({
|
8 | connectionString: 'amqp://localhost',
|
9 | retryWait: 100
|
10 | });
|
11 |
|
12 | hutch.on('ready', function() {
|
13 | console.log('Established RabbitMQ connection');
|
14 | console.log("Hutch Status:" + hutch.status);
|
15 | console.log("Hutch Configuration:" + JSON.stringify(hutch.configuration));
|
16 | setup();
|
17 | });
|
18 |
|
19 | function setup(){
|
20 |
|
21 | var consumer = function(message, done, fail) {
|
22 | hutch.destroy(options.queue.name, options.exchange.name, function(err){
|
23 | console.log("Queue has been destroyed");
|
24 | done();
|
25 | });
|
26 | };
|
27 |
|
28 | var options = {
|
29 | exchange: {
|
30 | name: 'example.exchange.1',
|
31 | type: 'topic'
|
32 | },
|
33 | queue: {
|
34 | name: 'example.queue',
|
35 | prefetch: 1,
|
36 | durable: true
|
37 | },
|
38 | publish: {
|
39 | persistent: true,
|
40 | expiration: 86400000
|
41 | }
|
42 | };
|
43 |
|
44 | hutch.consume(options, consumer, function(err) {
|
45 | console.log('Consumer Setup....');
|
46 |
|
47 | hutch.publish(options, "Example Message!", function(err, res){
|
48 | console.log("*** Message Sent ***");
|
49 | });
|
50 | });
|
51 | }
|
52 |
|
53 |
|