Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Message Selectors

 
Shobana Niranjan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
Parameters:
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.
Throws:
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic