-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (50 loc) · 1.16 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var amqp = require( 'amqp' );
var connection = amqp.createConnection(
{
host : 'localhost'
}
);
// Wait for connection to become established.
connection.on( 'ready', function () {
console.log( 'established connection' );
// set up new exchange
connection.exchange( 'immediate' );
connection.queue(
'clean.up.execution',
{
autoDelete: false,
durable: true
},
function( q ) {
q.bind( 'immediate', 'clean.up.execution', function() {
console.log( 'subscribing' );
q.subscribe( function( msg, headers, deliveryInfo ) {
console.log( 'joooo' );
console.log( msg );
console.log( headers );
} );
} );
}
);
// Use the default 'amq.topic' exchange
connection.queue(
'clean.up',
{
arguments:{
'x-dead-letter-exchange' :'immediate',
'x-message-ttl' : 1000,
'x-expires' : 2000,
}
},
function() {
console.log( 'publishing message' );
connection.publish(
'clean.up',
'jojo'
);
}
);
connection.on( 'close', function() {
console.log( 'done.' );
} );
} );