File tree Expand file tree Collapse file tree 1 file changed +9
-23
lines changed Expand file tree Collapse file tree 1 file changed +9
-23
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' ) ;
4
- var when = require ( 'when' ) ;
3
+ var amqp = require ( 'amqplib/callback_api' ) ;
5
4
6
- var conn = amqp . connect ( 'amqp://localhost' ) ;
7
- 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' ;
8
8
9
- function createChannel ( conn ) {
10
- return when (
11
- conn . createChannel ( ) .
12
- then ( sendMessage ) ) .
13
- ensure ( function ( ) {
14
- conn . close ( ) ;
15
- } ) ;
16
- }
17
-
18
- function sendMessage ( ch ) {
19
- var q = 'hello' ;
20
- var ok = ch . assertQueue ( q , { durable : false } ) ;
21
-
22
- return ok . then ( function ( _ignore ) {
23
- var msg = 'Hello World!' ;
24
- ch . sendToQueue ( q , new Buffer ( msg ) ) ;
25
- console . log ( " [x] Sent '%s'" , msg ) ;
26
- return ch . close ( ) ;
9
+ ch . assertQueue ( q ) ;
10
+ ch . sendToQueue ( q , new Buffer ( 'Hello World!' ) ) ;
11
+ console . log ( " [x] Sent 'Hello World!'" ) ;
27
12
} ) ;
28
- }
13
+ setTimeout ( function ( ) { conn . close ( ) ; process . exit ( 0 ) } , 500 ) ;
14
+ } ) ;
You can’t perform that action at this time.
0 commit comments