| Oracle9i Application Developer's Guide - Advanced Queuing Release 2 (9.2) Part Number A96587-01 |
|
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:

See Also:
|
Start a JMS Connection for receiving messages.
The start method is used to start (or restart) the connection's delivery of incoming messages.
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 Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Get the JMS Connection from a Session
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Commit All Operations in a Session
This method commits all JMS and SQL operations performed in this session.
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 Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Rollback All Operations in a Session
This method aborts all JMS and SQL operations performed in this session.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Get the Underlying JDBC Connection from a JMS session
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.
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
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();

See Also:
|
Get the underlying OracleOCIConnectionPool from a JMS connection.
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.
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
oracle.jdbc.pool.OracleOCIConnectionPool cpool; QueueConnection jms_conn; cpool = ((AQjmsConnection)jms_conn).getOCIConnectionPool();

See Also:
|
Create a Bytes Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Create a Map Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Create a Stream Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Create an Object Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Create a Text Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Create a JMS message
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:
DBMS_AQ.JMS_TEXT_MESSAGEDBMS_AQ.JMS_OBJECT_MESSAGEDBMS_AQ.JMS_MAP_MESSAGEDBMS_AQ.JMS_BYTES_MESSAGEDBMS_AQ.JMS_STREAM_MESSAGE
| See Also:
Oracle9i Supplied PL/SQL Packages and Types Reference for more information on JMS types. |
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Create a header-only JMS message
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. |
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Create an ADT Message
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available f.nctions in each programmatic environment.

See Also:
|
Specify message correlation ID.
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

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

Specify Message Property as Boolean
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as String
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as Int
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as Double
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as Float
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as Short
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

Specify Message Property as Object
Only objectified primitive values supported - Boolean, Byte, Short, Integer, Long, Float, Double and String.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Set Default TimeToLive for All Messages Sent by a Message Producer
TimetoLive is specified in milliseconds. It is calculated after the message is in ready state (i.e after message delay has taken effect).
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
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);

See Also:
|
Set Default Priority for All Messages Sent by a Message Producer
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.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.
/* Set default priority value to 2 for all messages sent by the QueueSender*/ QueueSender sender; sender.setPriority(2);
/* Set default priority value to 2 for all messages sent by the TopicPublisher*/ TopicPublisher publisher; publisher.setPriority(1);

See Also:
|
Create an AQjms Agent
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Receive a Message Using a Message Consumer by Specifying Timeout
Not applicable.
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
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);

See Also:
|
Receive a Message Using a Message Consumer Without Waiting
Not applicable.
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
See Chapter 3, "AQ Programmatic Environments" for a list of available functions in each programmatic environment.

See Also:
|
Specify the navigation mode for receiving messages.
Not applicable.
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
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();

See Also:
|
Specify a Message Listener at the Message Consumer
Not applicable.
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