Last active
August 29, 2015 14:24
-
-
Save duncanfinney/661f010a5d926f105005 to your computer and use it in GitHub Desktop.
AMQP Node.js Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var amqp = require('amqp'); | |
| var connection = amqp.createConnection({ | |
| host: '192.168.64.10', | |
| port: 5672 | |
| }); | |
| // Wait for connection to become established. | |
| connection.on('ready', function () { | |
| console.log('ready'); | |
| // Use the default 'amq.topic' exchange | |
| connection.queue('my-queue', function (q) { | |
| // Catch all messages | |
| q.bind('#'); | |
| // Receive messages | |
| q.subscribe(function (message) { | |
| // Print messages to stdout | |
| console.log('got a message: ', message); | |
| }); | |
| q.subscribe(function(message) { | |
| console.log('got a message 2: ', message); | |
| }) | |
| connection.publish('my-queue', { hello: 'world' }); | |
| connection.publish('my-queue', { hello: 'world' }); | |
| connection.publish('my-queue', { hello: 'world' }); | |
| connection.publish('my-queue', { hello: 'world' }); | |
| connection.publish('my-queue', { hello: 'world' }); | |
| connection.publish('my-queue', { hello: 'world' }); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment