File tree Expand file tree Collapse file tree 1 file changed +10
-20
lines changed Expand file tree Collapse file tree 1 file changed +10
-20
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env node
2
2
3
- var amqp = require ( 'amqplib' ) ;
3
+ var amqp = require ( 'amqplib/callback_api ' ) ;
4
4
5
- var conn = amqp . connect ( 'amqp://localhost' ) ;
6
- conn . then ( createChannel ) . then ( null , console . warn ) ;
5
+ amqp . connect ( 'amqp://localhost' , function ( err , conn ) {
6
+ conn . createChannel ( function ( err , ch ) {
7
+ var q = 'hello' ;
7
8
8
- function createChannel ( conn ) {
9
- process . once ( 'SIGINT' , function ( ) { conn . close ( ) ; } ) ;
10
- return conn . createChannel ( ) . then ( consume ) ;
11
- }
12
-
13
- function consume ( ch ) {
14
- var ok = ch . assertQueue ( 'hello' , { durable : false } ) ;
15
-
16
- ok = ok . then ( function ( _ignore ) {
17
- return ch . consume ( 'hello' , function ( msg ) {
18
- console . log ( " [x] Received '%s'" , msg . content . toString ( ) ) ;
19
- } , { noAck : true } ) ;
20
- } ) ;
21
-
22
- return ok . then ( function ( _consumeOk ) {
23
- console . log ( ' [*] Waiting for messages. To exit press CTRL+C' ) ;
9
+ ch . assertQueue ( q , { durable : false } ) ;
10
+ console . log ( " [*] Waiting for messages in %s. To exit press CTRL+C" , q ) ;
11
+ ch . consume ( q , function ( msg ) {
12
+ console . log ( " [x] Received %s" , msg . content . toString ( ) ) ;
13
+ } , { noAck : true } ) ;
24
14
} ) ;
25
- }
15
+ } ) ;
You can’t perform that action at this time.
0 commit comments