Integration between Node.js and ActiveMQ - how to use

As mentioned by Flame_Phoenix, you can easily use HTTP protocol to publish and receive messages

Publish

Receive

For more information: https://activemq.apache.org/rest


Disclaimer

It has been some time since I posted this, and for future reference I am posting my findings here. These findings relate my experience and as of the date of this post they are as accurate as possible.

Answers

Q1: Given that STOMP is a protocol, if I find a NPM library for any of the other protocols, can I use Node.js with that given protocol?

A1: The answer is yes. For example, using a MQTT library for Node.js, I can communicate with the ActiveMQ broker. There are usually some quirks that one has to considerate, but it definitely works.


Q2: If such libraries exist, can you point some?

A2:

  • MQTT: mqtt
  • AMQP 1.0 : amp10 and rhea. They don't work out of the box - see Unable to connect to Apache ActiveMQ with Node.js
  • STOMP: The recommended STMOPIT library.

Personally I would like to at least see the MQTT library added to the official documentation, as I believe it would help clear many questions from users.


Q3: Are there any caveats in using Node.js and ActiveMQ with another protocol other than STOMP?

A3: Yes. ActiveMQ has weird authentication requirements which lead to clients using a protocol's supported version to fail on connect (an example is with the previous AMQP 1.0 npm library). Furthermore, each library has its quirks, that you need to check. Usually the library's github page or issues page will give you some light on the integration issues with ActiveMQ, but it helps if the creators state clear support for ActiveMQ (which is not always the case).


Q4: Is it possible to use any of the EIPs that ActiveMQ offers with Node.js? If so, how?

A4: I believe this would still be possible via the REST DSL with XML (even though we don't use Spring nor anything like that) but I can't find anything nor anyone actually using it. The community failed to provide any feedback regarding this matter, as it seems to be very dependent on Java technologies, without knowledge in other other field.

Conclusion

Overall, if you have a Java project, you would be fine using ActiveMQ. If you want to use anything else, I strongly recommend avoiding it.

Everything either needs Java or some level of integration with it.

You could argue that ActiveMQ supports a large variety of protocols, but so do other tools that actually have support for your own language.

Even in the end, the EIPs provided by Camel, are not really available for for anything other than Java and even the community suggests you implement the patterns yourself, which defeats the whole purpose of using ActiveMQ.

Sources

Community thread: http://activemq.2283324.n4.nabble.com/Integration-between-Node-js-and-ActiveMQ-how-to-use-td4725822.html

Specials thanks to "Gordon Sim-2" the author of rhea. Cool project, go check it out !