Reputation: 31
I am using ActiveMQ, Spring.
Is there any way by which I can keep track of all processed messages. I have to keep track what all messages has been processed. I also want to review these processed messages at later stage.
Upvotes: 2
Views: 2200
Reputation: 70959
Kartik,
This is a good programming question, but it's more of a what should I program question rather than a "How can I do this" question. It's hard to answer a "What should I program question" because what you should program depends directly on what you need. At best, we can only guess at what you really need.
If you need to update the processed JMS messages, then a database will make it easy to update. If you need to prove that nobody updated a "logged" entry, then a database might not do the job.
Let's say this log is used to see which very slow to process messages still need to complete. Then a database will provide easy searching, provided that the person searching knows SQL. However, if the log is more of an archive, then the database just adds overhead to the entire process, a structured file will do.
In Java there is JDBC for writing and retrieving to databases, and it is not a hard API to use. Then again, there is also a number of decent logging frameworks, and of course there is always FileOutputStream. Without knowing how this log is to be used, it is very difficult to determine which techniques are really overkill, likewise it's not possible to know which techniques are not quite enough.
Go back and review how the log is to be used, and then evaluate if the features that databases provide are overkill.
Cheers, Ed
Upvotes: 0
Reputation: 42834
Upvotes: 1
Reputation: 2772
In general, I would suggest that you either log and/or record the messages into the database. If you simply want to review the messages later, simple logging may suffice. If you need to do transactional rollup/searching through a UI, then the database is better.
However, you can also achieve what you want with ActiveMQ virtual destinations. With this, you can have 1 destination forward to 2 other destinations. Then your app could listen on 1 destination, and a copy of the message would sit on the other for your review. For example:
<broker persistent="false" useJmx="false" xmlns="http://activemq.apache.org/schema/core">
<destinationInterceptors>
<virtualDestinationInterceptor>
<virtualDestinations>
<compositeQueue name="MY.QUEUE">
<forwardTo>
<queue physicalName="MY.QUEUE.PROCESS" />
<topic physicalName="MY.QUEUE.REVIEW" />
</forwardTo>
</compositeQueue>
</virtualDestinations>
</virtualDestinationInterceptor>
</destinationInterceptors>
</broker>
Would define a queue MY.QUEUE where each message would end up in BOTH the .PROCESS and .REVIEW queues.
Upvotes: 1