-
1. Re: My MdB receives the same message again and again
schausson Feb 9, 2009 5:16 AM (in response to schausson)I forgot to make clear some basics :
I use jboss-4.2.0.GA
My message producer sends a single message to a dedicated queue, that's why I would like to view my message processed once :) -
2. Re: My MdB receives the same message again and again
jaikiran Feb 9, 2009 5:45 AM (in response to schausson)Looks like a transaction timeout issue. So assuming that you used org.jboss.annotation.ejb.TransactionTimeout annotation (for JBoss-4.x), the timeout shouldn't have occured. How long does the processing take? And after increasing the timeout, does it fail again after 5 minutes or does it fail after the 'x' seconds that you have set?
Also please post appropriate logs which show this behaviour and also relevant piece of code where you are processing the message and persisting it.
While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted. -
3. Re: My MdB receives the same message again and again
schausson Feb 9, 2009 5:59 AM (in response to schausson)The processing might take from a few seconds to dozens of minutes, depending on the message content...
But to reply to your question, even with the org.jboss.annotation.ejb.TransactionTimeout annotation (I specified 100000 seconds just to give it a try), the processing stops after 'about' 5 minutes...
The full code of my onMessage() method :
/**
* {@inheritDoc}
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout(value=100000)
public void onMessage(Message arg0)
{
final ObjectMessage om = (ObjectMessage)arg0;
try {
System.out.println("received message : " + arg0);
final MyParameter plp = (MyParameter)om.getObject();
myProcessingMethod(plp); // This method might take dozens of minutes...
} catch (JMSException e) {
logger.logError(e);
} catch (Exception e) {
System.out.println("#############################################################################");
e.printStackTrace();
}
}
By the way, I also tried to implement the callback method setMessageDrivenContext(MessageDrivenContext) to store the context in a Mdb field so that I can check ctx.getRollbackOnly(), but it seems that the container does not invoke this method ... Did I miss something here as well ? -
4. Re: My MdB receives the same message again and again
schausson Feb 10, 2009 3:39 AM (in response to schausson)Well I finally made it work by moving most of my processing code in a SLSB that is invoked from my MdB, and for which I can tune transactions : I set a 100000 seconds timeout on the entry point method, and set a REQUIRES_NEW transaction attributes on other methods to split my processing in multiple 'small' transactions.
As a conclusion, the issue was following :
1 - transaction timeout seems to be not supported for MdB
2 - REQUIRES_NEW is unavailable for MdB methods and does not allowed me to break my long-running process into multiple transactions.
PS : The messageDrivenContext can be injected using the @Resource annotation (instead of overriding the setter method (EJB2.X old way...) that was not called by the container anyway)