Reputation: 8985
I used this guide to make a simple Spring boot in-memory ActiveMQ service that takes a message from a rest controller then passes it to a listener. Then the listener does some processing which takes about 40 seconds, but I have no way of retrieving the result after it was processed.
https://github.com/TechPrimers/inmemory-spring-boot-activemq-example
Everything is working as expected so far, but I want to be able to retrieve the results the listener has processed.
One way I am thinking about doing this is by creating another rest controller that returns the result of the task the listener finished. And by using a relational database to manage the IDs and messages.
However I would rather use everything in memory and not deal with a database.
Does ActiveMQ and/or spring have anything built in for managing that?
Upvotes: 1
Views: 4002
Reputation: 34998
What you're describing sounds to me like a request-reply pattern which is common in enterprise integration scenarios.
Assuming that the results of the work will be consumed fairly quickly then I would recommend you simply put the results into another message and send that message to a "reply" queue. The original message can include a "correlation ID" which the listener can use in the reply message as well so the results can be correlated with the request.
If the results will not be consumed fairly quickly then a database is probably better as message brokers aren't designed to be data repositories like databases are. Also, there are in-memory, embedded databases out there that would probably work well for you if you went that route.
Upvotes: 1