File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Message Selectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Message Selectors" Watch "Message Selectors" New topic

Message Selectors

Shobana Niranjan

Joined: Sep 03, 2002
Posts: 8
How do we write a message selector whose values for the variables are known only at runtime? I have to write a mdb that selects specific messages using a selector.Though the names of the variables will be known , the values of the variables will be known only at runtime.(dependant on the database). Any suggestions?
Thanks in advance
Amit G Piplani
Ranch Hand

Joined: Jul 21, 2004
Posts: 83
Then you have to go for QueueSession's createReceiver method
public QueueReceiver createReceiver(Queue queue,
java.lang.String messageSelector)
throws JMSExceptionCreates a QueueReceiver object to receive messages from the specified queue using a message selector.
queue - the Queue to access
messageSelector - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
JMSException - if the session fails to create a receiver due to some internal error.
InvalidDestinationException - if an invalid queue is specified.
InvalidSelectorException - if the message selector is invalid.

MessageSelector should have the check/condition for the given property

I agree. Here's the link:
subject: Message Selectors
It's not a secret anymore!