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