Search code examples
springjmsactivemq-classic

Spring Events vs ActiveMQ


Newbee to Spring world. I have some knowledge on ActiveMQ. Recently used in one of my projects. While reading about Spring Events raised a doubt.

Spring Events: Publisher -> Listener. We do publish events and we would have created some listeners for that.

ActiveMQ: Publisher -> Listener. We do publish events and we would have created some listeners for that.

So anyone helps me to understand the use cases or difference between these two APIs.


Solution

  • As far as I can tell, Spring Events are an application level events mechanism, so that different parts inside our application can communicate/coordinate. The scope and functionality appear to be quite narrow and small respectively. You can publish events and deal with those events either synchronously (default behaviour) or asynchronously (using @EnableAsync and @Async). There is no broker. This functionality may be a perfect fit for your application if this is all it needs.

    On the other hand, ActiveMQ is a full-featured message broker. Generally speaking, it runs as an independent server process (although it can be embedded in your application). It supports industry-standard protocols like AMQP, MQTT, & STOMP which have client implementations on numerous platforms and in various languages. For example, you could send STOMP messages via Websockets from a Javascript client and process those messages with an AMQP client written in .NET on Windows. It provides both a JMS & JNDI client implementation. It supports both publish-subscribe and point-to-point semantics. You can use it as an integration platform and scale it up to multi-node clusters with high-availability for the message data and thousands of remote clients using various protocols or you can embed it into your application and just use it for local events.