Skip to content

Instantly share code, notes, and snippets.

@duncanfinney
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save duncanfinney/661f010a5d926f105005 to your computer and use it in GitHub Desktop.

Select an option

Save duncanfinney/661f010a5d926f105005 to your computer and use it in GitHub Desktop.

Revisions

  1. duncanfinney revised this gist Jul 9, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,5 @@ connection.on('ready', function () {
    connection.publish('my-queue', { hello: 'world' });
    connection.publish('my-queue', { hello: 'world' });

    });
    });
    });
  2. duncanfinney created this gist Jul 9, 2015.
    31 changes: 31 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    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' });

    });