To expand, the following is the scenario I desire:
1. A message is posted to a persistent topic
2. An MDB reads the message and does it's business logic (the MDB may be across the network)
3. The client application stores the message persistently before doing anything else
4. The client application sends an acknowledgement to the server stating that the message was received
5. The server receives the acknowledgement
6. The server marks the message in the topic for deletion
7. The message is deleted from the persistent topic
Another angle that would work for solving my problem is if there is any way to store the message persistently before the MDB (or any other subscriber) returns the ack to the topic. Is there any way to do that? Can anyone point me in the right direction on where to read about this problem?
By the way, if I need to use queues instead of topics to make this happen, I would be interested in hearing about that as well.
If anyone can help, it would be GREATLY appreciated. Thank you!
I believe I have resolved my issue. The trick is to use the CLIENT_ACKNOWLEDGE. I believe the default is AUTO_ACKNOWLEDGE.
This should work with any subscriber, but for an MDB, I just needed to add <acknowledge-mode>CLIENT_ACKNOWLEDGE</acknowledge-mode> to my ejb-jar.xml, add a Message.acknowledge(); to my onMessage() within the MDB, and modify my creation of the session to be topicConnection.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);
For more information, see the following links:
You can also add transction required to your ejb-jar.xml
Yes, and it turns out that AUTO_ACKNOWLEDGE is already doing what I want it to do. AUTO_ACKNOWLEDGE is meant to send the ack at the end of the onMessage() method, so that actually meets my needs. I was making it harder on myself than I needed. ;-)
Anyone interested in learning more about acknowledgment modes or transactional messages should read the following article: