-
Regarding onMessage() call of an MDB (2 messages)
- Posted by: Sandeep K M
- Posted on: September 11 2007 02:28 EDT
Hi, I am very new to MDB’s. I want to do a simple check for a connection to my backend before executing the onMessage() method of my MDB. Is there any way by which I can prevent the EJB container from calling the onMessage(). Basically I want to execute the onMessage() only if my check condition passes. The logic should be some thing like below: if(Connection.status == running){ onMessage(){} } Do we have any facilities to do some think like above? Or else what I want to do is to check the connection condition inside onMessage() call and I want to block the further processing of the messages in the queue, some thing as shown below: onMessage(){ if(Connection.status == running){ // Process further }else{ // Block further processing and also the calls to onMessage() by the container } } Any body who know how to do the below: 1. I want to execute the onMessage() only if my check condition passes. 2. How to block further processing of the onMessage() by the EJB container till my condition check passes Thanks & Regards -SandeepThreaded Messages (2)
- Re: Regarding onMessage() call of an MDB by D S on September 11 2007 08:08 EDT
- Regarding onMessage() call of an MDB by Norbert Toth-Gati on September 20 2007 11:42 EDT
-
Re: Regarding onMessage() call of an MDB[ Go to top ]
- Posted by: D S
- Posted on: September 11 2007 08:08 EDT
- in response to Sandeep K M
Is there any way by which I can prevent the EJB container from calling the onMessage()
No. You will have to check inside the onMessage method. You can suspend (undeploy) an MDB using JMX. The exact details will vary depending on the application server you are using so you will need to read the documentation for that. Also, you can resume (deploy) the bean again using a similar mechanism once your status passes the check. Bear in mind, however, that you will not be able to do this inside onMessage because onMessage will never get called once the MDB has been suspended, so you will need some other means of resuming the bean. -
Regarding onMessage() call of an MDB[ Go to top ]
- Posted by: Norbert Toth-Gati
- Posted on: September 20 2007 11:42 EDT
- in response to Sandeep K M
1. I want to execute the onMessage() only if my check condition passes.
There is no possibility to block the onMessage() method of your MDB to be called. What I can think of as a solution for your problem is the following: you should make the check and see if the conditions are fulfilled in the onMessage() method. Only then process the message if the conditions passed. If they didn't pass, you must make sure the message is not lost. You can choose from one of the approaches:
2. How to block further processing of the onMessage() by the EJB container till my condition check passes- make the queue redeliver the message (it works with the JBoss AS only with CMT)
- rewrite the message in the queue Hope this helps! Cheers, Norbert