• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>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 ))

reply
    Bookmark Topic Watch Topic
  • New Topic