• 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

JMS - Achieving gaurateed sending of messages in the Queue

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working with Weblogic 7.1 and using JMS.
I have a component which populates the Queue with messages and a MDB which send messages to the client. Now the problem am facing is,
One Component puts messages in queue, and mdb (onMessage()) called and it tries to send mail. Now suppose smtp(mail) server is down for some reason. So no message delivary takes place. Now when the mail server is up again, unsent messages (which i suppose are recollected by messengin service and kept in queue)are to be sent again.Sending of unsent messages is not happenning. How do we achieve this.
Hope anyone has usefull hint for this issue.
Thanks in advance
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How is your MDB handling the situation where the mail server is not running? If you're simply swallowing any exceptions and returning from onMessage(), the message you just read from the queue won't be put back. You need to throw an exception...
[ February 03, 2004: Message edited by: Lasse Koskela ]
 
Chetan M
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
..the message you just read from the queue won't be put back. You need to throw an exception...


Well Lasse, i am throwing an exception, but doing nothing with the message. How do i populate queue with the unsent message?.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If inside onMessage() you are throwing an exception, the message should be automatically put back into the queue.
If you are throwing an exception, than something else is wrong...show us some code; from it we might figure out what the problem is.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is...
What type of transactioning is configured for your MDB?
 
Chetan M
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris , MDB is configured as Container managed one.
 
Chetan M
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sergui, am not throwing any exception instead, loging msg to file n console in the case as shown below.
public void onMessage(Message msg)
{
....
Transport.send(message);
}
catch(JMSException ex)
{
LogTrace.info(ex.getMessage(),ex);
}
catch(SendFailedException sfex)
{
LogTrace.severe(sfex.getMessage(),sfex);

}....
}
If inside onMessage() i throw an exception, are you sure that message is put back into the queue? and any specific exception to be thrown ?
 
Chris Mathews
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chetan M:
Sergui, am not throwing any exception instead, loging msg to file n console in the case as shown below.


That is your problem... since you are not throwing a system exception and you are not explicitly rolling back the transaction then the message is essentially being discarded.

Originally posted by Chetan M:
If inside onMessage() i throw an exception, are you sure that message is put back into the queue? and any specific exception to be thrown?


Yes, the container is required to place the message back on the Queue if your transaction is marked for rollback. An EJB Container will only automatically mark a transaction to rollback if you throw a system exception (pretty much anything extending from RuntimeException).
FYI, this may not solve your problem completely because the message will just get put back on the Queue and immediately consumed again. Most JMS Providers allow a configurable delay time before the message is resent to deal with these types of situations. Check your JMS Provider's documentation for more details.
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chetan, I have also posted this on your other topic:

Throw a system exception or rollback the transaction. For example:
inside your MDB you have:
private MessageDrivenContext ctx;
public void onMessage(Message msg){
....
//if you want to put the message back into the queue
ctx.setRollbackOnly();

Try these options.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic