Spring Events vs ActiveMQ
Asked Answered
H

1

9

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.

Hydrophone answered 6/3, 2019 at 5:6 Comment(2)
ActiveMQ is JMS, Spring events are a simple event mechanism. Both are quite different beasts with different usecases.Annettannetta
JMS is designed to support local application events and distributed messaging. A key advantage to coding to JMS is that your application can use an embedded broker for local application eventing, and then scale to multi-server distributed events without any code change! However, if you code to Spring Events, you'll need to re-factor the app if those events need to become distributed.Shiverick
L
13

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.

Leifeste answered 6/3, 2019 at 16:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.