Message Selectors

  GigaSpaces 5.X

Documentation Home
Quick Start Guide
Release Notes

Previous release

  Search Here
Searching GigaSpaces Platform 5.X Documentation

                                               

Summary: Allowing the JMS provider, instead of each client, to select messages for deletion.

Overview

Message consuming applications differ in nature. While some can process all the messages they receive from a particular topic or queue, other applications must select which messages they wish to process.
The most direct way for an application to consume messages is to first receive all messages and afterwards delete the ones it does not want.
The best way to circumvent this problem is by using Message Selectors. With Message Selectors the JMS provider selects the messages it wants to delete, instead of each client. Using Message Selectors simplifies client usage, resulting in a decrease in the amount of network traffic.
For a client to use Message Selectors it must employ a conditional expression, based on the message's headers. Such a conditional expression can refer to any application-defined, JMS-defined, or provider-specific property. It can also refer to any JMS header (with the exception of JMSDestination and JMSReplyTo).
The example below demonstrates a client subscribing to messages on a topic. This client is filtering incoming messages according to an application-defined message property called price. This example presumes that messages have a user-defined property price:

Topic topic = session.createTopic("bank.alltrades");
String selector = "price BETWEEN 10 and 100";
boolean noLocal=false;
 
TopicSubscriber subscriber=session.createSubscriber(topic,
selector, noLocal);

The argument noLocal designates whether or not the messages produced by its own connection should be sent.
The appropriate syntax is defined according to JMS specifications. The basis is the WHERE syntax of the SQL92 standard.

For details and examples on this syntax, refer to Javadocs for the javax.jms.Message interface.

Support for local transactions in the Enterprise Messaging Grid is implemented using the native facilities of the underlying messaging product. If such products do not support transactions, the Enterprise Messaging Grid framework itself will support them.
Support for JMS message selectors in the Enterprise Messaging Grid is implemented using the native facilities of the underlying messaging product. If such products do not support JMS message selectors, the Enterprise Messaging Grid framework itself will support them.


Wiki Content Tree


Your Feedback Needed!

We need your help to improve this wiki site. If you have any suggestions or corrections, write to us at techw@gigaspaces.com. Please provide a link to the wiki page you are referring to.

Labels

 
(None)