Forums Register Login

How to pause listener on MDB ?

+Pie Number of slices to send: Send
Hello Techies,

I am using MDB for message processing, inside which i have some condition, if condition is false then i don't want to read the message, i.e. i don't want to lose the message.

Can any one tell me how to prevent MDB to read the message.

Regards,

Aalok
+Pie Number of slices to send: Send
This is pretty straight forward , inside the onMessage Method , check for the condition whatever you want to perform first

+Pie Number of slices to send: Send
@Ravi Kiran,

I per my knowledge and J2EE Specs., onMessage(Message msg) is only for processing the message, not reading the message.

message is read by Container and then given to onMessage() method for processing.

and my problem is that... i don't want to read the message if condition is false i.e. that message must not be removed (read out) from JMS Queue.


Regards,
Aalok
1
+Pie Number of slices to send: Send
I currently dont remember exactly how to do this , but as per my knowledge you need to google on
"Configuring MDB Message Selectors"

and for this to work you need to set Header properties to your Message also .

Google it you will find it .
+Pie Number of slices to send: Send
 

Aalok Singh wrote:Can any one tell me how to prevent MDB to read the message.



Aalok

My understanding is that you cannot stop an instance of a MDB from receiving a message once a queue/topic selects that instance to receive the message.

If you don't want to process the message at the time it is received by an instance of the MDB then you can set a property within the message header that indicates the message processing should be delayed and place the message back into the queue/topic or into another queue/topic so that it can be processed later. Below is an example of setting this message property on JBoss. Note that the property name "JMS_JBOSS_SCHEDULED_DELIVERY" is specific to JBoss, thus it will be different on another server.

+Pie Number of slices to send: Send
 

Ravi Kiran Va wrote:I currently dont remember exactly how to do this , but as per my knowledge you need to google on
"Configuring MDB Message Selectors"

and for this to work you need to set Header properties to your Message also .

Google it you will find it .



before sending a message to a queue or topic add a property to it which would uniquely identify it like

.
.
ObjectMessage obj = session.createObjectMessage();
obj.setStringProperty("type","XYZ");
.
.

and when configuring the listener or the mdb to listen to a queue and pickup only messages which have type "XYZ"

String messageSelector = "type = 'XYZ'"
TopicSubscriber sub = session.createSubscriber(topicName,messageSelector,true);

there are numerous operators other than '=', you can even do a wildcard match for the messageSelector like "'type LIKE 'XYZ%'"
this is with reference to ActiveMQ. the creation of subscriber might vary depending upon the third party provider.
I am displeased. You are no longer allowed to read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3380 times.
Similar Threads
MDB in sequence diagram
Doubt in JMS
MDB state
JMS scheduling - help
Help on Message Driven Beans
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:21:53.