Suppressing local publications

 

We can create a message consumer that ignores publications published on the consumer's own connection. To do this, set the third parameter on the createConsumer() call to true, as shown in the following example:

// Create a nondurable message consumer with the noLocal option set
MessageConsumer con = session.createConsumer( topic, null, true );

The example that follows shows how to create a durable topic subscriber that applies a selector and ignores local publications:

// Create a durable, noLocal subscriber with a selector applied
String selector = "company = 'IBM'";
TopicSubscriber sub = session.createDurableSubscriber( topic, "D_SUB_000001",
                                                      selector, true );


uj25130_