09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating a Durable Subscriber for a JMS Topic with Selector<br />

pattern-value is a string literal where % refers to any sequence of<br />

characters and _ refers to any single character. The optional<br />

escape-character is used to escape the special meaning of the<br />

'_' and '%' in pattern-value<br />

identifier IS [NOT] NULL<br />

A client can change an existing durable subscription by creating a durable<br />

TopicSubscriber with the same name and a different message selector. An<br />

unsubscribe call is needed to end the subscription to the topic.<br />

Syntax<br />

Java (JDBC): <strong>Oracle</strong>9i Supplied Java Packages Reference oracle.jms,<br />

AQjmsTopicPublisher.publish<br />

Example<br />

Example 1 - subscribe specifying selector<br />

TopicConnectionFactory tc_fact = null;<br />

TopicConnection t_conn = null;<br />

TopicSession jms_sess;<br />

TopicSubscriber subscriber1;<br />

Topic shipped_orders;<br />

int myport = 5521;<br />

AQjmsAgent[] recipList;<br />

/* create connection and session */<br />

tc_fact = AQjmsFactory.getTopicConnectionFactory("MYHOSTNAME",<br />

"MYSID", myport, "oci8");<br />

t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");<br />

jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);<br />

shipped_orders = ((AQjmsSession )jms_sess).getTopic("OE", "Shipped_Orders_<br />

Topic");<br />

/* create a subscriber */<br />

/* with condition on JMSPriority and user property 'Region' */<br />

subscriber1 = jms_sess.createDurableSubscriber(shipped_orders,<br />

'WesternShipping',<br />

"JMSPriority > 2 and Region like 'Western%'",<br />

false);<br />

15-28 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!