Skip Headers

Oracle9i Application Developer's Guide - Advanced Queuing
Release 2 (9.2)

Part Number A96587-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

16
JMS Operational Interface: Basic Operations (Shared Interfaces)

In this chapter we describe the operational interface (shared interfaces) to Oracle Advanced Queuing in terms of use cases. That is, we discuss each operation (such as "Enqueue a Message") as a use case by that name. The table listing all the use cases is provided at the head of the chapter (see " Use Case Model: Operational Interface -- Basic Operations (Shared Interfaces)" ).

A summary figure, "Use Case Diagram: Operational Interface -- Basic Operations", locates all the use cases in a single drawing. If you are using the HTML version of this document, you can use this figure to navigate to the use case that interests you by clicking on the relevant use case title.

Each use case is laid out as follows:

Use Case Model: JMS Operational Interface -- Basic Operations (Shared Interfaces)

Table 16-1  Use Case Model: Operational Interface -- Basic Operations (Shared Interfaces)
Use Case

Starting a JMS Connection

Getting the JMS Connection from a Session

Committing All Operations in a Session

Rolling Back All Operations in a Session

Getting the Underlying JDBC Connection from a JMS Session

Getting the Underlying OracleOCIConnectionPool from a JMS Connection

Creating a Bytes Message

Creating a Map Message

Creating a Stream Message

Creating an Object Message

Creating a Text Message

Creating a JMS Message

Creating a JMS Message (Header Only)

Creating an ADT Message

Specifying Message Correlation ID

Specifying JMS Message Property

Specifying JMS Message Property as Boolean

Specifying JMS Message Property as String

Specifying JMS Message Property as Int

Specifying JMS Message Property as Double

Specifying JMS Message Property as Float

Specifying JMS Message Property as Byte

Specifying JMS Message Property as Long

Specifying JMS Message Property as Short

Specifying JMS Message Property as Object

Setting Default TimeToLive for All Messages Sent by a Message Producer

Setting Default Priority for All Messages Sent by a Message Producer

Creating an AQjms Agent

Receiving a Message Synchronously Using a Message Consumer by Specifying Timeout

Receiving a Message Synchronously Using a Message Consumer Without Waiting

Specifying the Navigation Mode for Receiving Messages

Specifying a Message Listener to Receive a Message Asynchronously at the Message Consumer

Specifying a Message Listener to Receive a Message Asynchronously at the Session

Getting the Correlation ID of a Message

Getting the Message ID of a Message as Bytes

Getting the Message ID of a Message as a String

Getting the JMS Message Property

Getting the JMS Message Property as a Boolean

Getting the JMS Message Property as a String

Getting the JMS Message Property as Int

Getting the JMS Message Property as Double

Getting the JMS Message Property as Float

Getting the JMS Message Property as Byte

Getting the JMS Message Property as Long

Getting the JMS Message Property as Short

Getting the JMS Message Property as Object

Closing a Message Producer

Closing a Message Consumer

Stopping a JMS Connection

Closing a JMS Session

Closing a JMS Connection

Getting the Error Code for the JMS Exception

Getting the Error Number for the JMS Exception

Getting the Error Message for the JMS Exception

Getting the Exception Linked to the JMS Exception

Printing the Stack Trace for the JMS Exception

Setting the Exception Listener

Getting the Exception Listener

Setting the Ping Period for the Exception Listener

Getting the Ping Period for the Exception Listener

Starting a JMS Connection

Figure 16-1 Starting a JMS Connection

Text description of adque119.gif follows
Text description of the illustration adque119.gif


See Also:

Purpose

Start a JMS Connection for receiving messages.

Usage Notes

The start method is used to start (or restart) the connection's delivery of incoming messages.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Connection from a Session

Figure 16-2 Getting the JMS Connection from a Session

Text description of adque147.gif follows
Text description of the illustration adque147.gif


See Also:

Purpose

Get the JMS Connection from a Session

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.getJmsConnection

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Committing All Operations in a Session

Figure 16-3 Committing All Operations in a Session

Text description of adque124.gif follows
Text description of the illustration adque124.gif


See Also:

Purpose

Commit All Operations in a Session

Usage Notes

This method commits all JMS and SQL operations performed in this session.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Rolling Back All Operations in a Session

Figure 16-4 Rolling Back All Operations in a Session

Text description of adque125.gif follows
Text description of the illustration adque125.gif


See Also:

Purpose

Rollback All Operations in a Session

Usage Notes

This method aborts all JMS and SQL operations performed in this session.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.rollback

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Underlying JDBC Connection from a JMS Session

Figure 16-5 Getting the Underlying JDBC Connection from a JMS Session

Text description of adque127.gif follows
Text description of the illustration adque127.gif


See Also:

Purpose

Get the Underlying JDBC Connection from a JMS session

Usage Notes

This method is used to obtain the underlying JDBC connection from a JMS session. The JDBC connection may be used to perform SQL operations as part of the same transaction that the JMS operations are done.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.getDBConnection

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

java.sql.Connection db_conn;
QueueSession     jms_sess;
db_conn = ((AQjmsSession)jms_sess).getDBConnection();

Getting the Underlying OracleOCIConnectionPool from a JMS Connection

Figure 16-6 Getting the Underlying OracleOCIConnectionPool from a JMS Connection

Text description of adque429.gif follows
Text description of the illustration adque429.gif


See Also:

Purpose

Get the underlying OracleOCIConnectionPool from a JMS connection.

Usage Notes

This method is used to obtain the underlying OracleOCIConnectionPool instance from a JMS connection. The settings of the OracleOCIConnectionPool instance may be tuned by the user depending on the connection usage, for example, the number of sessions the user wants to create using the given connection. The user should not, however, close the OracleOCIConnectionPool instance being used by the JMS connection.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConnection.getOCIConnectionPool

Examples

oracle.jdbc.pool.OracleOCIConnectionPool cpool;
QueueConnection jms_conn;
cpool = ((AQjmsConnection)jms_conn).getOCIConnectionPool();

Creating a Bytes Message

Figure 16-7 Creating a Bytes Message

Text description of adque129.gif follows
Text description of the illustration adque129.gif


See Also:

Purpose

Create a Bytes Message

Usage Notes

This method can be used only if the queue table that contains the destination queue/topic was created with the SYS.AQ$_JMS_BYTES_MESSAGE or AQ$_JMS_MESSAGE payload types.

Refer to Java Packages Reference for methods used to populate a BytesMessage.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createBytesMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating a Map Message

Figure 16-8 Creating a Map Message

Text description of adque130.gif follows
Text description of the illustration adque130.gif


See Also:

Purpose

Create a Map Message

Usage Notes

This method can be used only if the queue table that contains the destination queue/topic was created with the SYS.AQ$_JMS_MAP_MESSAGE or AQ$_JMS_MESSAGE payload types.

Refer to Java Packages Reference for methods used to populate a MapMessage.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createMapMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating a Stream Message

Figure 16-9 Creating a Stream Message

Text description of adque131.gif follows
Text description of the illustration adque131.gif


See Also:

Purpose

Create a Stream Message

Usage Notes

This method can be used only if the queue table that contains the destination queue/topic was created with the SYS.AQ$_JMS_STREAM_MESSAGE or AQ$_JMS_MESSAGE payload types.

Refer to Java Packages Reference for methods used to populate a StreamMessage.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createStreamMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating an Object Message

Figure 16-10 Creating an Object Message

Text description of adque132.gif follows
Text description of the illustration adque132.gif


See Also:

Purpose

Create an Object Message

Usage Notes

This method can be used only if the queue table that contains the destination queue/topic was created with the SYS.AQ$_JMS_OBJECT_MESSAGE or AQ$_JMS_MESSAGE payload types.

Refer to Java Packages Reference for methods used to populate a ObjectMessage.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createObjectMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating a Text Message

Figure 16-11 Creating a Text Message

Text description of adque133.gif follows
Text description of the illustration adque133.gif


See Also:

Purpose

Create a Text Message

Usage Notes

This method can be used only if the queue table that contains the destination queue/topic was created with the SYS.AQ$_JMS_TEXT_MESSAGE or AQ$_JMS_MESSAGE payload types.

Refer to Java Packages Reference for methods used to populate a Text Message.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createTextMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating a JMS Message

Figure 16-12 Creating a JMS Message

Text description of adque254.gif follows
Text description of the illustration adque254.gif


Purpose

Create a JMS message

Usage Notes

Use this ADT to store any or all of the JMS message types: bytes messages (JMSBytes), map messages (JMSMap), stream messages (JMSStream), object messages (JMSObject), or text messages (JMSText).

You can use the AQ$_JMS_MESSAGE construct message to construct messages of different types. The message type must be one of the following:

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating a JMS Message (Header Only)

Figure 16-13 Creating a JMS Message (Header Only)

Text description of adque255.gif follows
Text description of the illustration adque255.gif


Purpose

Create a header-only JMS message

Usage Notes

Use this ADT to store any or all of the JMS message types: bytes messages (JMSBytes), map messages (JMSMap), stream messages (JMSStream), object messages (JMSObject), or text messages (JMSText).

See Also:

Oracle9i Supplied PL/SQL Packages and Types Reference for more information on JMS types.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Creating an ADT Message

Figure 16-14 Creating an ADT Message

Text description of adque134.gif follows
Text description of the illustration adque134.gif


See Also:

Purpose

Create an ADT Message

Usage Notes

This method can be used only if the queue table that contains the queue/topic was created with an Oracle ADT payload_type (not one of the SYS.AQ$_JMS* types).

An ADT message must be populated with an object that implements the CustomDatum interface. This object must be the java mapping of the SQL ADT defined as the payload for the queue/topic. Java classes corresponding to SQL ADTs may be generated using the Jpublisher tool. Please refer to the JDBC documentation for details on CustomDatum interface and Jpublisher.

Refer to Java Packages Reference for methods used to populate AdtMessage.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.createAdtMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available f.nctions in each programmatic environment.

Specifying Message Correlation ID

Figure 16-15 Specifying Message Correlation ID

Text description of adque231.gif follows
Text description of the illustration adque231.gif


See Also:

Purpose

Specify message correlation ID.

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setJMSCorrelationID

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property

Figure 16-16 Specifying JMS Message Property

Text description of adque135.gif follows
Text description of the illustration adque135.gif


See Also:

Usage Notes

Property names starting with JMS are provider specific. User-defined properties cannot start with JMS.

The following provider properties may be set by clients using Text, Stream, Object, Bytes or Map Message:

The following properties may be set on AdtMessage

Specifying JMS Message Property as Boolean

Figure 16-17 Specifying Message Property as Boolean

Text description of adque136.gif follows
Text description of the illustration adque136.gif


See Also:

Purpose

Specify Message Property as Boolean

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setBooleanProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as String

Figure 16-18 Specifying Message Property as String

Text description of adque137.gif follows
Text description of the illustration adque137.gif


See Also:

Purpose

Specify Message Property as String

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setStringProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Int

Figure 16-19 Specifying Message Property as Int

Text description of adque138.gif follows
Text description of the illustration adque138.gif


See Also:

Purpose

Specify Message Property as Int

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setIntProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Double

Figure 16-20 Specifying Message Property as Double

Text description of adque139.gif follows
Text description of the illustration adque139.gif


See Also:

Purpose

Specify Message Property as Double

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setDoubleProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Float

Figure 16-21 Specifying Message Property as Float

Text description of adque140.gif follows
Text description of the illustration adque140.gif


See Also:

Purpose

Specify Message Property as Float

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setFloatProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Byte

Figure 16-22 Specifying Message Property as Byte

Text description of adque141.gif follows
Text description of the illustration adque141.gif


See Also:

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setByteProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Long

Figure 16-23 Use Case Diagram: Specifying Message Property as Long

Text description of adque142.gif follows
Text description of the illustration adque142.gif


See Also:

Purpose

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setLongProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Short

Figure 16-24 Specifying Message Property as Short

Text description of adque143.gif follows
Text description of the illustration adque143.gif


See Also:

Purpose

Specify Message Property as Short

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setShortProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying JMS Message Property as Object

Figure 16-25 Specifying Message Property as Object

Text description of adque144.gif follows
Text description of the illustration adque144.gif


See Also:

Purpose

Specify Message Property as Object

Usage Notes

Only objectified primitive values supported - Boolean, Byte, Short, Integer, Long, Float, Double and String.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.setObjectProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Setting Default TimeToLive for All Messages Sent by a Message Producer

Figure 16-26 Setting Default TimeToLive for All Messages Sent by a MessageProducer

Text description of adque152.gif follows
Text description of the illustration adque152.gif


See Also:

Purpose

Set Default TimeToLive for All Messages Sent by a Message Producer

Usage Notes

TimetoLive is specified in milliseconds. It is calculated after the message is in ready state (i.e after message delay has taken effect).

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsProducer.setTimeToLive

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

/* Set default timeToLive value to 100000 milliseconds for all messages sent by 
the QueueSender*/
QueueSender sender;
sender.setTimeToLive(100000);

Setting Default Priority for All Messages Sent by a Message Producer

Figure 16-27 Setting Default Priority for All Messages Sent by a Message Producer

Text description of adque158.gif follows
Text description of the illustration adque158.gif


See Also:

Purpose

Set Default Priority for All Messages Sent by a Message Producer

Usage Notes

Priority values can be any integer. A smaller number indicates higher priority.

If a priority value is explicitly specified during the send operation, it overrides the producer's default value set by this method.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsProducer.setPriority

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Example 1

/* Set default priority value to 2 for all messages sent by the QueueSender*/
QueueSender sender;
sender.setPriority(2);

Example 2

/* Set default priority value to 2 for all messages sent by the TopicPublisher*/
TopicPublisher publisher;
publisher.setPriority(1);

Creating an AQjms Agent

Figure 16-28 Creating an AQjmsAgent

Text description of adque163.gif follows
Text description of the illustration adque163.gif


See Also:

Purpose

Create an AQjms Agent

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsAgent

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Receiving a Message Synchronously Using a Message Consumer by Specifying Timeout

Figure 16-29 Receiving a Message Using a Message Consumer by Specifying Timeout

Text description of adque179.gif follows
Text description of the illustration adque179.gif


See Also:

Purpose

Receive a Message Using a Message Consumer by Specifying Timeout

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConsumer.receive

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

TopicConnectionFactory    tc_fact   = null;
TopicConnection           t_conn    = null;
TopicSession              t_sess    = null;
TopicSession              jms_sess;
Topic                     shipped_orders;
int                       myport = 5521;

/* create connection and session */
tc_fact = AQjmsFactory.getTopicConnectionFactory("MYHOSTNAME",
                                                  "MYSID", myport, "oci8");

t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");
jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);

shipped_orders = ((AQjmsSession )jms_sess).getTopic("WS",
"Shipped_Orders_Topic");

/* create a subscriber, specifying the correct CustomDatumFactory  and
selector */
subscriber1 = jms_sess.createDurableSubscriber(shipped_orders,
'WesternShipping', 
             " priority > 1 and tab.user_data.region like 'WESTERN %'",
              false,AQjmsAgent.getFactory());

/* receive, blocking for 30 seconds if there were no messages */
Message = subscriber.receive(30000);

Receiving a Message Synchronously Using a Message Consumer Without Waiting

Figure 16-30 Receiving a Message Using a Message Consumer Without Waiting

Text description of adque180.gif follows
Text description of the illustration adque180.gif


See Also:

Purpose

Receive a Message Using a Message Consumer Without Waiting

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConsumer.receiveNoWait

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specifying the Navigation Mode for Receiving Messages

Figure 16-31 Specifying the Navigation Mode for Receiving Messages

Text description of adque234.gif follows
Text description of the illustration adque234.gif


See Also:

Purpose

Specify the navigation mode for receiving messages.

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsQueueReceiver.setNavigationMode, AQjmsTopicReceiver.setNavigationMode, AQjmsTopicSubscriber.setNavigationMode

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

TopicConnectionFactory    tc_fact   = null;
TopicConnection           t_conn    = null;
TopicSession              t_sess    = null;
TopicSession              jms_sess;
Topic                     shipped_orders;
int                       myport = 5521;

/* create connection and session */

tc_fact = AQjmsFactory.getTopicConnectionFactory("MYHOSTNAME",
                                                  "MYSID", myport, "oci8");
t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");
jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);

shipped_orders = ((AQjmsSession )jms_sess).getTopic("WS",
"Shipped_Orders_Topic");
/* create a subscriber, specifying the correct CustomDatumFactory  and
selector */

subscriber1 = jms_sess.createDurableSubscriber(shipped_orders,
'WesternShipping',
                " priority > 1 and tab.user_data.region like 'WESTERN %'",
                  false,AQjmsAgent.getFactory());

subscriber1.setNavigationMode(AQjmsConstants.NAVIGATION_FIRST_MESSAGE);

/* get message for the subscriber, returning immediately if there was no
message */
Message = subscriber.receive();

Specifying a Message Listener to Receive a Message Asynchronously at the Message Consumer

Figure 16-32 Specifying a Message Listener at the Message Consumer

Text description of adque182.gif follows
Text description of the illustration adque182.gif


See Also:

Purpose

Specify a Message Listener at the Message Consumer

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConsumer.setMessageListener

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

TopicConnectionFactory    tc_fact   = null;
TopicConnection           t_conn    = null;
TopicSession              t_sess    = null;
TopicSession              jms_sess;
Topic                     shipped_orders;
int                       myport = 5521;
MessageListener           mLis = null;
/* create connection and session */
tc_fact = AQjmsFactory.getTopicConnectionFactory("MYHOSTNAME",
                                                  "MYSID", myport, "oci8");
t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic");
jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);

shipped_orders = ((AQjmsSession )jms_sess).getTopic("WS",
"Shipped_Orders_Topic");
/* create a subscriber, specifying the correct CustomDatumFactory  and
selector */
subscriber1 = jms_sess.createDurableSubscriber(shipped_orders,
'WesternShipping',
        " priority > 1 and tab.user_data.region like 'WESTERN %'",
         false,AQjmsAgent.getFactory());

mLis = new myListener(jms_sess, "foo");
/* get message for the subscriber, returning immediately if there was no
message */
subscriber.setMessageListener(mLis);

The definition of the myListener class
import oracle.AQ.*;
import oracle.jms.*;
import javax.jms.*;
import java.lang.*;
import java.util.*;
public class myListener implements MessageListener
{
   TopicSession   mySess;
   String         myName;

   /* constructor */
   myListener(TopicSession t_sess, String t_name)
   {
      mySess = t_sess;
      myName = t_name;
   }

   public onMessage(Message m)
   {
      System.out.println("Retrieved message with correlation: " ||
m.getJMSCorrelationID());

      try{
        /* commit the dequeue */
        mySession.commit();
      } catch (java.sql.SQLException e)
      {System.out.println("SQL Exception on commit"); }

   }

}

Specifying a Message Listener to Receive a Message Asynchronously at the Session

Figure 16-33 Specifying a Message Listener at the Session

Text description of adque128.gif follows
Text description of the illustration adque128.gif


See Also:

Purpose

Specify a Message Listener at the Session

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.setMessageListener

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Correlation ID of a Message

Figure 16-34 Getting the Correlation ID of a Message

Text description of adque183.gif follows
Text description of the illustration adque183.gif


See Also:

Purpose

Get the Correlation ID of a Message

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getJMSCorrelationID

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Message ID of a Message as Bytes

Figure 16-35 Getting the Message ID of a Message as Bytes

Text description of adque184.gif follows
Text description of the illustration adque184.gif


See Also:

Purpose

Get the Message ID of a Message as Bytes

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getJMSMessageID

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Message ID of a Message as a String

Figure 16-36 Getting the Message ID of a Message as a String

Text description of adque185.gif follows
Text description of the illustration adque185.gif


See Also:

Purpose

Get the Message ID of a Message as String

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getJMSMessageID

Examples

See Chapter 3, "AQ Programmatic Environments"for a list of available functions in each programmatic environment.

Getting the JMS Message Property

Figure 16-37 Getting the JMS Message Property

Text description of adque219.gif follows
Text description of the illustration adque219.gif


See Also:

Getting the JMS Message Property as a Boolean

Figure 16-38 Getting the Message Property as a Boolean

Text description of adque220.gif follows
Text description of the illustration adque220.gif


See Also:

Purpose

Get the Message Property as a Boolean

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getBooleanProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as a String

Figure 16-39 Getting the Message Property as a String

Text description of adque186.gif follows
Text description of the illustration adque186.gif


See Also:

Purpose

Get the Message Property as a String

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getStringProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

TextMessage message;

message.setStringProperty("JMS_OracleExcpQ", "scott.text_ecxcp_queue"); /*set 
exception queue for message*/

message.setStringProperty("color", "red"); /*set user-defined property - color 
*/

Getting the JMS Message Property as Int

Figure 16-40 Getting the Message Property as Int

Text description of adque221.gif follows
Text description of the illustration adque221.gif


See Also:

Purpose

Get the Message Property as Int

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getIntProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

StreamMessage message;
message.setIntProperty("MMS_OracleDelay", 10); /*set message delay to 10 
seconds*/

message.setIntProperty("empid", 1000); /*set user-defined property - empId*/

Getting the JMS Message Property as Double

Figure 16-41 Getting the Message Property as Double

Text description of adque222.gif follows
Text description of the illustration adque222.gif


See Also:

Purpose

Get the Message Property as Double

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getDoubleProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as Float

Figure 16-42 Getting the Message Property as Float

Text description of adque223.gif follows
Text description of the illustration adque223.gif


See Also:

Purpose

Get the Message Property as Float

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getFloatProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as Byte

Figure 16-43 Getting the Message Property as Byte

Text description of adque224.gif follows
Text description of the illustration adque224.gif


See Also:

Purpose

Get the Message Property as Byte

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getByteProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as Long

Figure 16-44 Getting the Message Property as Long

Text description of adque225.gif follows
Text description of the illustration adque225.gif


See Also:

Purpose

Get the Message Property as Long.

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getLongProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as Short

Figure 16-45 Getting the Message Property as Short

Text description of adque229.gif follows
Text description of the illustration adque229.gif


See Also:

Purpose

Get the Message Property as Short

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getShortProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the JMS Message Property as Object

Figure 16-46 Getting the Message Property as Object

Text description of adque226.gif follows
Text description of the illustration adque226.gif


See Also:

Purpose

Get the Message Property as Object

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsMessage.getObjectProperty

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

TextMessage message;
message.setObjectProperty("empid", new Integer(1000);

Closing a Message Producer

Figure 16-47 Closing a Message Producer

Text description of adque187.gif follows
Text description of the illustration adque187.gif


See Also:

Purpose

Close a Message Producer

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsProducer.close

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Closing a Message Consumer

Figure 16-48 Closing a Message Consumer

Text description of adque188.gif follows
Text description of the illustration adque188.gif


See Also:

Purpose

Close a Message Consumer

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConsumer.close

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Stopping a JMS Connection

Figure 16-49 Stopping a JMS Connection

Text description of adque120.gif follows
Text description of the illustration adque120.gif


See Also:

Purpose

Stop a JMS Connection

Usage Notes

This method is used to temporarily stop a Connection's delivery of incoming messages.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConnection.stop

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Closing a JMS Session

Figure 16-50 Closing a JMS Session

Text description of adque126.gif follows
Text description of the illustration adque126.gif


See Also:

Purpose

Close a JMS Session

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsSession.close

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Closing a JMS Connection

Figure 16-51 Closing a JMS Connection

Text description of adque121.gif follows
Text description of the illustration adque121.gif


See Also:

Purpose

Close a JMS Connection

Usage Notes

This method closes the connection and releases all resources allocated on behalf of the connection. Since the JMS provider typically allocates significant resources outside the JVM on behalf of a Connection, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsConnection.close

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Error Code for the JMS Exception

Figure 16-52 Getting the Error Code for the JMS Exception

Text description of adque189.gif follows
Text description of the illustration adque189.gif


See Also:

Purpose

Get the Error Code for the JMS Exception

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsException.getErrorCode

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Error Number for the JMS Exception

Figure 16-53 Getting the Error Number for the JMS Exception

Text description of adque227.gif follows
Text description of the illustration adque227.gif


See Also:

Purpose

Get the Error Number for the JMS Exception

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsException.getErrorNumber

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Error Message for the JMS Exception

Figure 16-54 Getting the Error Message for the JMS Exception

Text description of adque190.gif follows
Text description of the illustration adque190.gif


See Also:

Purpose

Get the Error Message for the JMS Exception

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsException.getMessage

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Getting the Exception Linked to the JMS Exception

Figure 16-55 Getting the Exception Linked to the JMS Exception

Text description of adque245.gif follows
Text description of the illustration adque245.gif


See Also:

Purpose

Get the Exception Linked to the JMS Exception

Usage Notes

This method is used to get the Exception linked to this JMS exception. In general, this contains the SQL Exception raised by the database.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsException.getLinkedException

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Printing the Stack Trace for the JMS Exception

Figure 16-56 Printing the Stack Trace for the JMS Exception

Text description of adque192.gif follows
Text description of the illustration adque192.gif


See Also:

Purpose

Print the Stack Trace for the JMS Exception

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms, AQjmsException.printStackTrace

Examples

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Setting the Exception Listener

Figure 16-57 Setting the Exception Listener

Text description of adque417.gif follows
Text description of the illustration adque417.gif


See Also:

Purpose

Specify an Exception Listener for the connection.

Usage Notes

If a serious problem is detected for the connection, the connection's ExceptionListener, if one has been registered, will be informed. This is done by calling the listener's onException() method, passing it a JMSException describing the problem. This allows a JMS client to be asynchronously notified of a problem. Some connections only consume messages, so they have no other way to learn the connection has failed.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms AQjmsConnection.setExceptionListener

Examples

//register an exception listener
Connection jms_connection;
jms_connection.setExceptionListener(
    new ExceptionListener() {
        public void onException (JMSException jmsException) {
            System.out.println("JMS-EXCEPTION: " + jmsException.toString());
        }
    };
  );

Getting the Exception Listener

Figure 16-58 Getting the Exception Listener

Text description of adque418.gif follows
Text description of the illustration adque418.gif


See Also:

Purpose

Get the Exception Listener for the connection.

Usage Notes

Not applicable.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms AQjmsConnection.getExceptionListener

Examples

//Get the exception listener
Connection jms_connection;
ExceptionListener el = jms_connection.getExceptionListener();

Setting the Ping Period for the Exception Listener

Figure 16-59 Setting the Ping Period for the Exception Listener

Text description of adque438.gif follows
Text description of the illustration adque438.gif


See Also:

Purpose

Specify the ping period for the Exception Listener.

Usage Notes

If an exception listener is set for the connection, the connection pings the database periodically to ensure that the database is accessible. The period is specified in milliseconds. The default value is 2 minutes. If an exception listener is not set for the connection, the database is not pinged. This method can be called before or after the exception listener is set.

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms AQjmsConnection.setPingPeriod

Examples

//set the ping period to 4 minutes
Connection jms_connection;
jms_connection.setPingPeriod(4*60*1000);

Getting the Ping Period for the Exception Listener

Figure 16-60 Getting the Ping Period for the Exception Listener

Text description of adque439.gif follows
Text description of the illustration adque439.gif


See Also:

Purpose

Get the ping period for the Exception Listener.

Usage Notes

If an exception listener is set for the connection, the connection pings the database periodically to ensure that the database is accessible. The period is specified in milliseconds. The default value is 2 minutes. If an exception listener is not set for the connection, the database is not pinged. This method will return the value of the period set by the last call to setPingPeriod. If setPingPeriod was never called, then the default value is returned

Syntax

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment. Use the following syntax references for each programmatic environment:

See Java (JDBC): Oracle9i Supplied Java Packages Reference oracle.jms AQjmsConnection.getPingPeriod

Examples

//get the ping period
Connection jms_connection;
long pp = jms_connection.getPingPeriod();

Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback