Home Ask Login Register

Developers Planet

Your answer is one click away!

user1624552 February 2016

Communication between two java classes using Spring

I have two java classes that implements Runnable within the same application, let's say A and B classes.

These two classes share a BlockingQueue to pass some data. Class A sends data to class B through BlockingQueue. Then class B takes the data and process it. What I am trying to do is that when some conditions happen in class B as a result of process this data, it sends a messages to class A, and class A prints these messages.

So I was having a look at Spring messaging using Apache ActiveMQ, but it seems a broker must be started in order communication works using "activemq start" command. Is there any possibility to do this without having this broker started?

What is the best option to do this? I would like to do this using Spring framework so can be done using some kind of approach in Spring? Or the only possiblity using spring is through apache activemq?


Gary Russell February 2016

Take a looks at Spring Integration; components communicate using Messages.

You can use an entirely in-memory configuration or provide persistence via some broker such as ActiveMQ.

The components themselves are not concerned with that; they simply send/receive messages.

David Zimmerman February 2016

Create the Queue in spring and inject it into both Runnables

Post Status

Asked in February 2016
Viewed 1,806 times
Voted 12
Answered 2 times


Leave an answer

Quote of the day: live life