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.

General Features of JMS<br />

A JMS Connection to the database can be created by invoking<br />

createQueueConnection() or createTopicConnection() and passing<br />

the parameters username and password on the QueueConnectionFactory and<br />

TopicConnectionFactory object respectively.<br />

Connection Setup<br />

A JMS client typically creates a Connection, Session and a number of<br />

MessageProducers and MessageConsumers. In the current version only one<br />

open session for each connection is allowed, except in the following cases:<br />

If the JDBC oci8 driver is used to create the JMS Connection<br />

If the user provides an <strong>Oracle</strong>OCIConnectionPool instance during JMS<br />

<br />

Connection creation<br />

When a Connection is created it is in stopped mode. In this state no messages can be<br />

delivered to it. It is typical to leave the Connection in stopped mode until setup is<br />

complete. At that point the Connection’s start() method is called and messages<br />

begin arriving at the Connection’s consumers. This setup convention minimizes any<br />

client confusion that may result from asynchronous message delivery while the<br />

client is still in the process of setup.<br />

It is possible to start a Connection and to perform setup subsequently. Clients that<br />

do this must be prepared to handle asynchronous message delivery while they are<br />

still in the process of setting up. A MessageProducer can send messages while a<br />

Connection is stopped.<br />

Some of the methods that are supported on the Connection object are<br />

start() - start, or restart, a Connection’s delivery of incoming messages.<br />

<br />

stop() - Used to temporarily stop a Connection’s delivery of incoming<br />

<br />

messages. When stopped, delivery to all the Connection’s message consumers<br />

is inhibited. Also, synchronous receive’s block and messages are not delivered<br />

to message listener<br />

close() - close the JMS session and release all associated resources<br />

createQueueSession(true, 0) - create a queue session<br />

createTopicSession (true, 0) - create a topic session<br />

setExceptionListener (ExceptionListener) - set an exception<br />

listener for the connection. This allows a client to be asynchronously notified of<br />

a problem. Some connections only consume messages so they have no other<br />

way to learn the connection has failed.<br />

Creating Applications Using JMS 12-9

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

Saved successfully!

Ooh no, something went wrong!