File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 11var amqp = require ( 'amqp' ) ;
2- var amqp_hacks = require ( './amqp-hacks' ) ;
32
4- var connection = amqp . createConnection ( { host : 'localhost' } ) ;
3+ var connection = amqp . createConnection ( { host : 'localhost' } ) ;
54
65connection . on ( 'ready' , function ( ) {
76 connection . queue ( 'hello' , { autoDelete : false } , function ( queue ) {
7+
8+ console . log ( ' [*] Waiting for messages. To exit press CTRL+C' )
9+
810 queue . subscribe ( function ( msg ) {
911 console . log ( " [x] Received %s" , msg . data . toString ( 'utf-8' ) ) ;
1012 } ) ;
1113 } ) ;
12- console . log ( ' [*] Waiting for messages. To exit press CTRL+C' )
1314} ) ;
Original file line number Diff line number Diff line change 11var amqp = require ( 'amqp' ) ;
22var amqp_hacks = require ( './amqp-hacks' ) ;
33
4- var connection = amqp . createConnection ( { host : 'localhost' } ) ;
4+ var connection = amqp . createConnection ( { host : 'localhost' } ) ;
55
66connection . on ( 'ready' , function ( ) {
77 connection . publish ( 'hello' , 'Hello World!' ) ;
Original file line number Diff line number Diff line change 1+ var amqp = require ( 'amqp' ) ;
2+
3+ var connection = amqp . createConnection ( { host : 'localhost' } ) ;
4+
5+ connection . on ( 'ready' , function ( ) {
6+ connection . queue ( 'task_queue' , { autoDelete : false ,
7+ durable : true } , function ( queue ) {
8+
9+ console . log ( ' [*] Waiting for messages. To exit press CTRL+C' ) ;
10+
11+ queue . subscribe ( { ack : true , prefetchCount : 1 } , function ( msg ) {
12+ var body = msg . data . toString ( 'utf-8' ) ;
13+ console . log ( " [x] Received %s" , body ) ;
14+ setTimeout ( function ( ) {
15+ console . log ( " [x] Done" ) ;
16+ queue . shift ( ) ; // basic_ack equivalent
17+ } , ( body . split ( '.' ) . length - 1 ) * 1000 ) ;
18+ } ) ;
19+ } ) ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments