Node red is a really nice framework that lets you build IoTs workflows. It is in fact far more interesting than that because you can use it in order to create small workflow integrations as you would do with a product like Mule or Camel. Of course you should not use it if you want to handle critical financial messages using a MQ Series transaction but it can handle most of the less critical cases.

Setup

We will work with ActiveMQ and RabbitMQ. In order to quickly setup a test environment with Docker, use the following docker-compose file.

version: '2'
services:

##############################
  nodered:
    image: nodered/node-red-docker
    container_name: nodered
    ports:
      - "1880:1880"

##############################
  amqc:
    image: snuids/activemq-amqcmonitoring:latest
    ports:
      - "5672:5672"
      - "8161:8161"
      - "61616:61616"
      - "61614:61614"
      - "61613:61613"
      - "1883:1883"
    container_name: amqc
    restart: always
    environment:
      - ACTIVEMQ_ADMIN_LOGIN=amquser
      - ACTIVEMQ_ADMIN_PASSWORD=amqpassword

##############################
  rabbitmq:
   image: rabbitmq:3.6.5-management
   container_name: rabbitmq
   ports:
     - 5671:5671
     - 5672:5672
     - 15672:15672
     - 61623:61613
     - 1893:1883
   environment:
     - RABBITMQ_DEFAULT_USER=rabbituser
     - RABBITMQ_DEFAULT_PASS=rabbitpassword

At this point:

Login and password are defined in the docker-compose file.

STOMP protocol

The stomp protocol is a simple protocol that can be used with most MQ systems. It works with RabbitMQ and ActiveMQ.

Setup

Open the nodered website and use the “Manage Palette” option in order to add the stomp widgets.

Screen Shot 2017-04-15 at 11.34.55

ActiveMQ

Configure your stomp node as shown below:

Screen Shot 2017-04-15 at 11.42.27Screen Shot 2017-04-15 at 11.41.06

Finish your node-red configuration like shown on the following screenshot:

Screen Shot 2017-04-15 at 11.47.21.jpg

If you use the ActiveMQ console to push message to the queue stomptesttonodered, it should appear in the queue: stomptesttoamq.

Unfortunately, it does not work as expected. The message is correctly read by the node red consumer but something goes wrong and the message is not displayed in the flow even if you add a debug node in your flow.

On the other hand, if you add an inject button, messages are correctly forwarded to ActiveMQ. So it looks like it is possible to push messages to ActiveMQ but that it is not possible to receive them in Node Red.

RabbitMQ

The RabbitMQ stomp protocol is not enabled by default. Get a bash prompt inside the container using the following command:

docker exec -it rabbitmq bash

And install the plugin via this command:

rabbitmq-plugins enable rabbitmq_stomp

Leave the container and restart active mq from the host:

docker restart rabbitmq

Same result as with ActiveMQ. It is possible to send messages. Node red consumes the messages but does not dispatch them in the flow. It looks like there is something wrong with the connector.

MQTT protocol

The mqtt protocol is a simple protocol that can be used with most MQ systems. It was designed for IoTs, but also works with RabbitMQ and ActiveMQ. MQTT is installed natively in Node Red.

ActiveMQ

Configure your MQTT node as shown below:

Screen Shot 2017-04-15 at 14.05.53Screen Shot 2017-04-15 at 14.05.46

Add an output node. And link them together.

Screen Shot 2017-04-15 at 14.19.42.jpg

This time it is working as expected. Messages are received and forwarded. Note that messages use topics and not queues which could be a problem with particular scenarios.

RabbitMQ

The RabbitMQ MQTT protocol is not enabled by default. Get a bash prompt inside the container using the following command:

docker exec -it rabbitmq bash

And install the plugin via this command:

rabbitmq-plugins enable rabbitmq_mqtt

Leave the container and restart active mq from the host:

docker restart rabbitmq

It is possible to send data from node red via mqtt. The message will arrive on the exchange amq.topic. A routing key matching the topic name set in node red must be added in order to forward the messages to a particular queue.

Screen Shot 2017-04-15 at 14.39.20.jpg

I was not able to get any message in Node-Red via MQTT.

AMQP

The AMQP protocol is a new protocol which is supported by most of the recent brokers. There is a node that supports it.

Screen Shot 2017-04-15 at 14.43.57.jpg

ActiveMQ

I was unfortunately unable to make it work with ActiveMQ.

RabbitMQ

It was working as expected (Read and Write) with Rabbit MQ.

Summary

ActiveMQ

Node-Red writes via STOMP. Reads and Writes topics via MQTT.

RabbitMQ

Node-Red writes via STOMP. Writes via MQTT. Reads and writes via AMQP.

Conclusion

It is not as solid as Camel but it definitively can help in a lot of scenarios.