aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible?" Watch "JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible?" New topic
Author

JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible?

Dimka Noneen
Greenhorn

Joined: Apr 10, 2010
Posts: 3
Hi!

In general I have MDB which consums messages and call onMessage method. And the problem is that messages
will be deleted when MDB will be called to proceed message. So, it is only one chance to process this
message. I dont want to resend the message again, so setRollbackOnly not a solution.

So the question is - is it possible to delete message from inbox queue only after success processing the message?
Or to put a message back to inbox queue with less priority?

I thing that it is bad solution because of it will cycle and it is hard to controll it.

JBM 1.4

Thanks.
Jonh Smith
Ranch Hand

Joined: Mar 18, 2010
Posts: 39
I'm not sure i understand your question but...

"is it possible to delete message from inbox queue only after success processing the message? "

yes. if you're using CMT, this is the behaviour the container provides you automatically if you're using the REQUIRED transaction attribute (the default). if some problem results in a system (runtime) exception, the container automatically rollbacks your changes, including putting the message back in the queue.

if you're using BMT, the spec states that:

5.4.14 Message Acknowledgment for JMS Message-Driven Beans
JMS message-driven beans should not attempt to use the JMS API for message acknowledgment. Message
acknowledgment is automatically handled by the container. If the message-driven bean uses container-
managed transaction demarcation, message acknowledgment is handled automatically as a part of
the transaction commit. If bean-managed transaction demarcation is used, the message receipt cannot be
part of the bean-managed transaction, and, in this case, the receipt is acknowledged by the container.
If
bean-managed transaction demarcation is used, the Bean Provider can indicate whether JMS
AUTO_ACKNOWLEDGE semantics or DUPS_OK_ACKNOWLEDGE semantics should apply by using the
activationConfig element of the MessageDriven annotation or by using the activation-
config-property deployment descriptor element. The property name used to specify the
acknowledgment mode is acknowledgeMode. If the acknowledgeMode property is not specified,
JMS AUTO_ACKNOWLEDGE semantics are assumed. The value of the acknowledgeMode property
must be either Auto-acknowledge or Dups-ok-acknowledge for a JMS message-driven bean.


I've never used BMT with MDBs so someone more experienced should help you but my interpretation of the quote above - taking into consideration the normal non-mdb semantics of jms acknowledgment - is that rolling back just by itself (calling the UserTransaction.rollback method ) will not put the message back in the queue, but if you would throw a runtime exception from the onMessage method the container should not acknowledge the receipt and therefore the message would not be dequeued.

"the problem is that messages will be deleted when MDB will be called to proceed message".

Actually, as i've tried to show you, this is not necessarily true.

Please do let me know if I'm wrong about the bmt stuff. I don't have the time to test it.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

I dont want to resend the message again, so setRollbackOnly not a solution.

So the question is - is it possible to delete message from inbox queue only after success processing the message?


If an error is encountered while message processing, the standard approach is to not acknowledge the message so that it is redelivered.

ram.
Dimka Noneen
Greenhorn

Joined: Apr 10, 2010
Posts: 3
>>yes. if you're using CMT, this is the behaviour the container provides you automatically if you're using the REQUIRED transaction attribute (the default). if some problem results in a system (runtime) exception, the container automatically rollbacks your changes, including putting the message back in the queue.


Thanks, I read MDB spec and cannot understand that the transaction begins from removing a message from queue.
On exception it will be redelivered.

But I have solved this problem - not to try save message in inbox queue ))

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JBoss Messanging: keeping message in inbox queue until it will be processed successfully - possible?