Skip to content

Instantly share code, notes, and snippets.

@Jazeem
Last active November 8, 2017 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jazeem/3294cae5120266cfacfc551a62b89886 to your computer and use it in GitHub Desktop.
Save Jazeem/3294cae5120266cfacfc551a62b89886 to your computer and use it in GitHub Desktop.
Simple flow to connect listen to messages published in RabbitMQ

Uses the node-red-contrib-amqp node to listen to messages published to a queue in RabbitMQ and display it in debug output

Install node-red https://nodered.org/docs/getting-started/installation
Install node-red-contrib-amqp https://www.npmjs.com/package/node-red-contrib-amqp
Install RabbitMQ https://www.rabbitmq.com/download.html

Run rabbitmq-server
Login to web UI using username 'guest' and password 'guest'
Create new queue test-queue

Publish messages to this queue from terminal by
./rabbitmqadmin publish exchange=amq.default routing_key=test-queue payload="hello, world"

See messages in node-red debug window

[{"id":"5fafbb51.1fd9b4","type":"tab","label":"Flow 1"},{"id":"6b1cb95.2baed48","type":"inject","z":"5fafbb51.1fd9b4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":156.5,"y":141,"wires":[["e1a95443.665058"]]},{"id":"e1a95443.665058","type":"debug","z":"5fafbb51.1fd9b4","name":"","active":true,"console":"false","complete":"false","x":433.5,"y":143,"wires":[]},{"id":"456ecdae.887d84","type":"amqp in","z":"5fafbb51.1fd9b4","name":"","topic":"","iotype":"4","ioname":"test-queue","server":"f9ec9a1a.ccac58","x":137.5,"y":255,"wires":[["e1a95443.665058"]]},{"id":"f9ec9a1a.ccac58","type":"amqp-server","z":"","host":"localhost","port":"5672","vhost":"","keepalive":"30","usetls":false,"verifyservercert":true,"usetopology":false,"topology":"{\n\t\"exchanges\": [\n\t\t{\"name\": \"exchange1\", \"type\": \"direct\", \"options\": {\"durable\": false}},\n\t\t{\"name\": \"exchange2\"}\n\t],\n\t\"queues\": [\n\t\t{\"name\": \"queue1\", \"options\": {\"messageTtl\": 60000}},\n\t\t{\"name\": \"queue2\"}\n\t],\n\t\"bindings\": [\n\t\t{\"source\": \"exchange1\", \"queue\": \"queue1\", \"pattern\": \"debug\", \"args\": {}},\n\t\t{\"source\": \"exchange1\", \"exchange\": \"exchange2\", \"pattern\": \"error\"},\n\t\t{\"source\": \"exchange2\", \"queue\": \"queue2\"}\n\t]\n}"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment