-
1. Re: Persistence - control the marking of messages to be dele
flindet Oct 28, 2004 9:51 PM (in response to flindet)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
Thanks -
2. Re: Persistence - control the marking of messages to be dele
flindet Oct 29, 2004 11:32 AM (in response to flindet)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! -
3. Re: Persistence - control the marking of messages to be dele
flindet Nov 4, 2004 1:32 PM (in response to flindet)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:
http://docs.jboss.org/admin-devel/Chap6.html
http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Session.html#CLIENT_ACKNOWLEDGE -
4. Re: Persistence - control the marking of messages to be dele
genman Nov 4, 2004 8:10 PM (in response to flindet)
You can also add transction required to your ejb-jar.xml
<assembly-descriptor>
<container-transaction>
<ejb-name>MDBBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar> -
5. Re: Persistence - control the marking of messages to be dele
flindet Nov 5, 2004 3:50 PM (in response to flindet)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:
http://www.javaworld.com/javaworld/jw-03-2002/jw-0315-jms.html