Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publish-Subscribe in spring? [closed]

Can any one tell me how to use the Publish-Subscribe pattern in Spring? Does Spring have any built-in functionality to implement this?

In Java we can do like this: http://www.avajava.com/tutorials/lessons/observer-pattern.html .

like image 559
Human Being Avatar asked Feb 16 '23 22:02

Human Being


1 Answers

Spring is Java; obviously you can use any Java pattern in Spring, with the additional benefits of Spring (IoC and AOP in particular). Spring itself provides its own events that can be used to do it.

Spring Integration brings a ton of Java EE patterns to Spring, including Pubsub. It may be a bit heavy for simplistic use cases; something like RabbitMQ and Spring's AMQP support is lighter.

PubSub is just a pattern: there are a ton of ways to implement it. Which makes the most sense depends on a lot of factors. Consider searching a bit more on the web before asking such a broad question; there are a ton of resources covering a wide range of implementation choices.

like image 53
Dave Newton Avatar answered Feb 27 '23 12:02

Dave Newton