PK
-Aoa, mimetypeapplication/epub+zipPK -A iTunesMetadata.plistR
This chapter describes new features of the Oracle Database 11g Release 1 (11.1) and provides pointers to additional information. There are no new features for 11g Release 2 (11.2).
The following notification enhancements are introduced:
AQ Event Notification Infrastructure provides asynchronous communication of database events from the suppliers/publishers of their events to the consumers/registrations. The event monitor sends these notifications. In order to meet the demands of increased notification use, the notification server in 11g is enhanced to a parallel notification server consisting of a coordinator and a set of subordinate processes. The parallel notification server offers a capability to process a greater volume of notifications, faster notification processing and lower shared memory use for staging notification events.
Sometimes a very large number of events occur in the database and it is important that applications not be overwhelmed with notifications. The preferred strategy is for notifications to be grouped and delivered at application-specified intervals and in application-specified formats. Oracle Streams AQ provides the infrastructure for notification grouping by time for AQ and DBCHANGE
namespaces. Users have the option of specifying the grouping time interval and the predefined format in which to be notified at the end of those grouping intervals. Users can also specify when to start sending grouping notifications and how many times to send grouping notifications.
The following sections describe diagnosability:
This release adds new performance views for persistent messaging statistics and notification statistics. The Automatic Workload Repository (AWR) has also been enhanced for displaying queues with the most persistent messaging operations, allowing for easier diagnosability of AQ performance problems.
New dictionary views are provided to simplify subscription management for Oracle Streams Advanced Queuing. DBA_SUBSCR_REGISTRATIONS
and USER_SUBSCR_REGISTRATIONS
identify registered subscriptions, as well as detail information on the subscriptions. Runtime statistics for notifications are available with the V$SUBSCR_REGISTRATION_STATS
view.
Export import of queues is now fully supported at queue table level granularity. The user only needs to export the queue table. All the queues in the queue table, primary object grants, related objects like views, IOTs, rules are automatically exported.
EMON PL/SQL notifications are executed by background jobs. In this release these jobs are DBMS_SCHEDULER
jobs and are no longer conducted by DBMS_JOBS
.
The init.ora
parameter job_queue_processes
does not need to be set for PL/SQL notifications or AQ propagations.
AQ propagation is now likewise handled by DBMS_SCHEDULER jobs rather than DBMS_JOBS
. Additionally, propagation takes advantage of the event based scheduling features of DBMS_SCHEDULER for better scalability.
The following Messaging Gateway enhancements are introduced:
The Oracle Scheduler will be used to start Messaging Gateway agents. Messaging Gateway will leverage the Oracle Scheduler RAC service feature so that a Messaging Gateway agent is associated with a database service. If the instance on which a Messaging Gateway agent is running fails or is shutdown, the Oracle Scheduler will automatically restart the agent on another instance supporting that service.
Messaging Gateway is enhanced to enable multiple agents per instance and database. With this enhancement, you can now statically partition propagation jobs based on functionality, organizations, or workload and assign them to different MGW agents hosted by different database instances on different machines. This not only enables MGW to scale, but also enables propagation job grouping and isolation, which is important when MGW is used in a complicated application integration environment.
An enhanced PL/SQL API consolidates the propagation subscriber and the propagation schedule into a new propagation job. It is now easier to create and schedule a propagation job for the messaging gateway.
A list of error messages is provided to aid you in troubleshooting problems.
This chapter describes the components of the Oracle Streams Advanced Queuing (AQ) Java Message Service (JMS) operational interface that are specific to publish/subscribe operations. Components that are shared by point-to-point and publish/subscribe are described in Chapter 15, "Oracle JMS Shared Interfaces".
This chapter contains these topics:
Creating a Connection with Default ConnectionFactory Parameters
Creating a TopicConnection with an Open OracleOCIConnectionPool
Publishing Messages Specifying Delivery Mode, Priority and TimeToLive
Creating a DurableSubscriber for a JMS Topic Without Selector
Creating a DurableSubscriber for an Oracle Object Type Topic Without Selector
Creating a DurableSubscriber for an Oracle Object Type Topic With Selector
Creating a Remote Subscriber for Oracle Object Type Messages
Unsubscribing a Durable Subscription for a Remote Subscriber
Creating a TopicReceiver for a Topic of Standard JMS Type Messages
Creating a TopicReceiver for a Topic of Oracle Object Type Messages
Creating a TopicBrowser for Standard JMS Messages, Locking Messages
Creating a TopicBrowser for Oracle Object Type Messages, Locking Messages
public javax.jms.Connection createConnection( java.lang.String username, java.lang.String password) throws JMSException
This method creates a connection supporting both point-to-point and publish/subscribe operations with the specified username and password. This method is new and supports JMS version 1.1 specifications. It has the following parameters:
Parameter | Description |
---|---|
username | Name of the user connecting to the database for queuing |
password | Password for creating the connection to the server |
public javax.jms.Connection createConnection() throws JMSException
This method creates a connection supporting both point-to-point and publish/subscribe operations with default ConnectionFactory parameters. This method is new and supports JMS version 1.1 specifications. If the ConnectionFactory
properties do not contain a default username and password, then it throws a JMSException.
public javax.jms.TopicConnection createTopicConnection( java.lang.String username, java.lang.String password) throws JMSException
This method creates a TopicConnection
with the specified username/password. It has the following parameters:
Parameter | Description |
---|---|
username | Name of the user connecting to the database for queuing |
password | Password for creating the connection to the server |
Example 14-1 Creating a TopicConnection with Username/Password
TopicConnectionFactory tc_fact = AQjmsFactory.getTopicConnectionFactory("sun123", "oratest", 5521, "thin"); /* Create a TopicConnection using a username/password */ TopicConnection tc_conn = tc_fact.createTopicConnection("jmsuser", "jmsuser");
public static javax.jms.TopicConnection createTopicConnection( java.sql.Connection jdbc_connection) throws JMSException
This method creates a TopicConnection
with open JDBC connection. It has the following parameter:
Parameter | Description |
---|---|
jdbc_connection | Valid open connection to database |
public static javax.jms.TopicConnection createTopicConnection( oracle.jdbc.pool.OracleOCIConnectionPool cpool) throws JMSException
This method creates a TopicConnection
with an open OracleOCIConnectionPool
. It is static and has the following parameter:
Parameter | Description |
---|---|
cpool | Valid open OCI connection pool to the database |
public javax.jms.Session createSession(boolean transacted, int ack_mode) throws JMSException
This method creates a Session
supporting both point-to-point and publish/subscribe operations. It is new and supports JMS version 1.1 specifications. It has the following parameters:
Parameter | Description |
---|---|
transacted | If set to true, then the session is transactional |
ack_mode | Indicates whether the consumer or the client will acknowledge any messages it receives. It is ignored if the session is transactional. Legal values are Session.AUTO_ACKNOWLEDGE , Session.CLIENT_ACKNOWLEDGE , and Session.DUPS_OK_ACKNOWLEDGE . |
public javax.jms.TopicSession createTopicSession(boolean transacted, int ack_mode) throws JMSException
This method creates a TopicSession
. It has the following parameters:
Parameter | Description |
---|---|
transacted | If set to true, then the session is transactional |
ack_mode | Indicates whether the consumer or the client will acknowledge any messages it receives. It is ignored if the session is transactional. Legal values are Session.AUTO_ACKNOWLEDGE , Session.CLIENT_ACKNOWLEDGE , and Session.DUPS_OK_ACKNOWLEDGE . |
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws JMSException
This method creates a TopicPublisher
. It has the following parameter:
Parameter | Description |
---|---|
topic | Topic to publish to, or null if this is an unidentified producer |
public void publish(javax.jms.Message message) throws JMSException
This method publishes a message with minimal specification. It has the following parameter:
Parameter | Description |
---|---|
message | Message to send |
The TopicPublisher
uses the default values for message priority
(1
) and timeToLive
(infinite
).
Example 14-6 Publishing Without Specifying Topic
/* Publish without specifying topic */ TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicPublisher publisher1; 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"); /* create TopicSession */ jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE); /* get shipped orders topic */ shipped_orders = ((AQjmsSession )jms_sess).getTopic( "OE", "Shipped_Orders_Topic"); publisher1 = jms_sess.createPublisher(shipped_orders); /* create TextMessage */ TextMessage jms_sess.createTextMessage(); /* publish without specifying the topic */ publisher1.publish(text_message);
Example 14-7 Publishing Specifying Correlation and Delay
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicPublisher publisher1; 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( "OE", "Shipped_Orders_Topic"); publisher1 = jms_sess.createPublisher(shipped_orders); /* Create TextMessage */ TextMessage jms_sess.createTextMessage(); /* Set correlation and delay */ /* Set correlation */ jms_sess.setJMSCorrelationID("FOO"); /* Set delay of 30 seconds */ jms_sess.setLongProperty("JMS_OracleDelay", 30); /* Publish */ publisher1.publish(text_message);
public void publish(javax.jms.Topic topic, javax.jms.Message message) throws JMSException
This method publishes a message specifying the topic. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to publish to |
message | Message to send |
If the TopicPublisher
has been created with a default topic, then the topic
parameter may not be specified in the publish()
call. If a topic is specified, then that value overrides the default in the TopicPublisher
. If the TopicPublisher
has been created without a default topic, then the topic must be specified with the publish()
call.
Example 14-8 Publishing Specifying Topic
/* Publish specifying topic */ TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicPublisher publisher1; 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); /* create TopicPublisher */ publisher1 = jms_sess.createPublisher(null); /* get topic object */ shipped_orders = ((AQjmsSession )jms_sess).getTopic( 'WS', 'Shipped_Orders_Topic'); /* create text message */ TextMessage jms_sess.createTextMessage(); /* publish specifying the topic */ publisher1.publish(shipped_orders, text_message);
public void publish(javax.jms.Topic topic, javax.jms.Message message, oracle.jms.AQjmsAgent[] recipient_list, int deliveryMode, int priority, long timeToLive) throws JMSException
This method publishes a message specifying delivery mode, priority and TimeToLive
. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to which to publish the message (overrides the default topic of the MessageProducer ) |
message | Message to publish |
recipient_list | List of recipients to which the message is published. Recipients are of type AQjmsAgent . |
deliveryMode | PERSISTENT or NON_PERSISTENT (only PERSISTENT is supported in this release) |
priority | Priority for this message |
timeToLive | Message lifetime in milliseconds (zero is unlimited) |
Example 14-9 Publishing Specifying Priority and TimeToLive
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicPublisher publisher1; 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( "OE", "Shipped_Orders_Topic"); publisher1 = jms_sess.createPublisher(shipped_orders); /* Create TextMessage */ TextMessage jms_sess.createTextMessage(); /* Publish message with priority 1 and time to live 200 seconds */ publisher1.publish(text_message, DeliveryMode.PERSISTENT, 1, 200000);
public void publish(javax.jms.Message message, oracle.jms.AQjmsAgent[] recipient_list) throws JMSException
This method publishes a message specifying a recipient list overriding topic subscribers. It has the following parameters:
Parameter | Description |
---|---|
message | Message to publish |
recipient_list | List of recipients to which the message is published. Recipients are of type AQjmsAgent . |
Example 14-10 Publishing Specifying a Recipient List Overriding Topic Subscribers
/* Publish specifying priority and timeToLive */ TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicPublisher publisher1; Topic shipped_orders; int myport = 5521; AQjmsAgent[] recipList; /* 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( "OE", "Shipped_Orders_Topic"); publisher1 = jms_sess.createPublisher(shipped_orders); /* create TextMessage */ TextMessage jms_sess.createTextMessage(); /* create two receivers */ recipList = new AQjmsAgent[2]; recipList[0] = new AQjmsAgent( "ES", "ES.shipped_orders_topic", AQAgent.DEFAULT_AGENT_PROTOCOL); recipList[1] = new AQjmsAgent( "WS", "WS.shipped_orders_topic", AQAgent.DEFAULT_AGENT_PROTOCOL); /* publish message specifying a recipient list */ publisher1.publish(text_message, recipList);
public javax.jms.TopicSubscriber createDurableSubscriber( javax.jms.Topic topic, java.lang.String subs_name) throws JMSException
This method creates a DurableSubscriber for a JMS topic without selector. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to subscribe to |
subs_name | Name used to identify this subscription |
Exclusive Access to Topics
CreateDurableSubscriber()
and Unsubscribe()
both require exclusive access to their target topics. If there are pending JMS send()
, publish()
, or receive()
operations on the same topic when these calls are applied, then exception ORA - 4020 is raised. There are two solutions to the problem:
Limit calls to createDurableSubscriber()
and Unsubscribe()
to the setup or cleanup phase when there are no other JMS operations pending on the topic. That makes sure that the required resources are not held by other JMS operational calls.
Call TopicSession.commit
before calling createDurableSubscriber()
or Unsubscribe()
.
Example 14-11 Creating a Durable Subscriber for a JMS Topic Without Selector
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int myport = 5521; AQjmsAgent[] recipList; /* 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( "OE", "Shipped_Orders_Topic"); /* create a durable subscriber on the shipped_orders topic*/ subscriber1 = jms_sess.createDurableSubscriber( shipped_orders, 'WesternShipping');
public javax.jms.TopicSubscriber createDurableSubscriber( javax.jms.Topic topic, java.lang.String subs_name, java.lang.String messageSelector, boolean noLocal) throws JMSException
This method creates a durable subscriber for a JMS topic with selector. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to subscribe to |
subs_name | Name used to identify this subscription |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
noLocal | If set to true, then it inhibits the delivery of messages published by its own connection |
A client can change an existing durable subscription by creating a durable TopicSubscriber with the same name and a different messageSelector
. An unsubscribe call is needed to end the subscription to the topic.
Example 14-12 Creating a Durable Subscriber for a JMS Topic With Selector
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int myport = 5521; AQjmsAgent[] recipList; /* 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( "OE", "Shipped_Orders_Topic"); /* create a subscriber */ /* with condition on JMSPriority and user property 'Region' */ subscriber1 = jms_sess.createDurableSubscriber( shipped_orders, 'WesternShipping', "JMSPriority > 2 and Region like 'Western%'", false);
public javax.jms.TopicSubscriber createDurableSubscriber( javax.jms.Topic topic, java.lang.String subs_name, java.lang.Object payload_factory) throws JMSException
This method creates a durable subscriber for an Oracle object type topic without selector. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to subscribe to |
subs_name | Name used to identify this subscription |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
Example 14-13 Creating a Durable Subscriber for an Oracle Object Type Topic Without Selector
/* Subscribe to an ADT queue */ TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int my[port = 5521; AQjmsAgent[] recipList; /* the java mapping of the oracle object type created by J Publisher */ ADTMessage message; /* 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( "OE", "Shipped_Orders_Topic"); /* create a subscriber, specifying the correct CustomDatumFactory */ subscriber1 = jms_sess.createDurableSubscriber( shipped_orders, 'WesternShipping', AQjmsAgent.getFactory());
public javax.jms.TopicSubscriber createDurableSubscriber( javax.jms.Topic topic, java.lang.String subs_name, java.lang.String messageSelector, boolean noLocal, java.lang.Object payload_factory) throws JMSException
This method creates a durable subscriber for an Oracle object type topic with selector. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to subscribe to |
subs_name | Name used to identify this subscription |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
noLocal | If set to true, then it inhibits the delivery of messages published by its own connection |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
Example 14-14 Creating a Durable Subscriber for an Oracle Object Type Topic With Selector
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int myport = 5521; AQjmsAgent[] recipList; /* the java mapping of the oracle object type created by J Publisher */ ADTMessage message; /* 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( "OE", "Shipped_Orders_Topic"); /* create a subscriber, specifying correct CustomDatumFactory and selector */ subscriber1 = jms_sess.createDurableSubscriber( shipped_orders, "WesternShipping", "priority > 1 and tab.user_data.region like 'WESTERN %'", false, ADTMessage.getFactory());
A transformation can be supplied when sending/publishing a message to a queue/topic. The transformation is applied before putting the message into the queue/topic.
The application can specify a transformation using the setTransformation
interface in the AQjmsQueueSender
and AQjmsTopicPublisher
interfaces.
Example 14-15 Sending Messages to a Destination Using a Transformation
Suppose that the orders that are processed by the order entry application should be published to WS_bookedorders_topic
. The transformation OE2WS (defined in the previous section) is supplied so that the messages are inserted into the topic in the correct format.
public void ship_bookedorders( TopicSession jms_session, AQjmsADTMessage adt_message) { TopicPublisher publisher; Topic topic; try { /* get a handle to the WS_bookedorders_topic */ topic = ((AQjmsSession)jms_session).getTopic("WS", "WS_bookedorders_topic"); publisher = jms_session.createPublisher(topic); /* set the transformation in the publisher */ ((AQjmsTopicPublisher)publisher).setTransformation("OE2WS"); publisher.publish(topic, adt_message); } catch (JMSException ex) { System.out.println("Exception :" ex); } }
A transformation can also be specified when creating topic subscribers using the CreateDurableSubscriber()
call. The transformation is applied to the retrieved message before returning it to the subscriber. If the subscriber specified in the CreateDurableSubscriber()
call already exists, then its transformation is set to the specified transformation.
Example 14-16 Specifying Transformations for Topic Subscribers
The Western Shipping application subscribes to the OE_bookedorders_topic with the transformation OE2WS
. This transformation is applied to the messages and the returned message is of Oracle object type WS.WS_orders
.
Suppose that the WSOrder java class has been generated by Jpublisher to map to the Oracle object WS.WS_order
:
public AQjmsAdtMessage retrieve_bookedorders(TopicSession jms_session) { TopicSubscriber subscriber; Topic topic; AQjmsAdtMessage msg = null; try { /* get a handle to the OE_bookedorders_topic */ topic = ((AQjmsSession)jms_session).getTopic("OE", "OE_bookedorders_topic"); /* create a subscriber with the transformation OE2WS */ subs = ((AQjmsSession)jms_session).createDurableSubscriber( topic, 'WShip', null, false, WSOrder.getFactory(), "OE2WS"); msg = subscriber.receive(10); } catch (JMSException ex) { System.out.println("Exception :" ex); } return (AQjmsAdtMessage)msg; }
public void createRemoteSubscriber(javax.jms.Topic topic, oracle.jms.AQjmsAgent remote_subscriber, java.lang.String messageSelector) throws JMSException
This method creates a remote subscriber for topics of JMS messages. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to subscribe to |
remote_subscriber | AQjmsAgent that refers to the remote subscriber |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
Oracle Streams Advanced Queuing allows topics to have remote subscribers, for example, subscribers at other topics in the same or different database. In order to use remote subscribers, you must set up propagation between the local and remote topic.
Remote subscribers can be a specific consumer at the remote topic or all subscribers at the remote topic. A remote subscriber is defined using the AQjmsAgent
structure. An AQjmsAgent
consists of a name and address. The name refers to the consumer_name
at the remote topic. The address refers to the remote topic. Its syntax is schema.topic_name[@dblink]
.
To publish messages to a particular consumer at the remote topic, the subscription_name
of the recipient at the remote topic must be specified in the name field of AQjmsAgent
, and the remote topic must be specified in the address field. To publish messages to all subscribers of the remote topic, the name field of AQjmsAgent
must be set to null.
Example 14-17 Creating a Remote Subscriber for Topics of JMS Messages
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int my[port = 5521; AQjmsAgent remoteAgent; /* 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( "OE", "Shipped_Orders_Topic"); remoteAgent = new AQjmsAgent("WesternRegion", "WS.shipped_orders_topic", null); /* create a remote subscriber (selector is null )*/ subscriber1 = ((AQjmsSession)jms_sess).createRemoteSubscriber( shipped_orders, remoteAgent, null);
public void createRemoteSubscriber(javax.jms.Topic topic, oracle.jms.AQjmsAgent remote_subscriber, java.lang.String messageSelector, java.lang.Object payload_factory) throws JMSException
This method creates a remote subscriber for topics of Oracle object type messages. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to subscribe to |
remote_subscriber | AQjmsAgent that refers to the remote subscriber |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
Oracle Streams Advanced Queuing allows topics to have remote subscribers, for example, subscribers at other topics in the same or different database. In order to use remote subscribers, you must set up propagation between the local and remote topic.
Remote subscribers can be a specific consumer at the remote topic or all subscribers at the remote topic. A remote subscriber is defined using the AQjmsAgent
structure. An AQjmsAgent
consists of a name and address. The name refers to the consumer_name
at the remote topic. The address refers to the remote topic. Its syntax is schema.topic_name[@dblink]
.
To publish messages to a particular consumer at the remote topic, the subscription_name
of the recipient at the remote topic must be specified in the name field of AQjmsAgent
, and the remote topic must be specified in the address field. To publish messages to all subscribers of the remote topic, the name field of AQjmsAgent
must be set to null.
Example 14-18 Creating a Remote Subscriber for Topics of Oracle Object Type Messages
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int my[port = 5521; AQjmsAgent remoteAgent; ADTMessage message; /* create connection and session */ tc_fact = AQjmsFactory.getTopicConnectionFactory( "MYHOSTNAME", "MYSID", myport, "oci8"); t_conn = tc_fact.createTopicConnection("jmstopic", "jmstopic"); /* create TopicSession */ jms_sess = t_conn.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE); /* get the Shipped order topic */ shipped_orders = ((AQjmsSession )jms_sess).getTopic( "OE", "Shipped_Orders_Topic"); /* create a remote agent */ remoteAgent = new AQjmsAgent("WesternRegion", "WS.shipped_orders_topic", null); /* create a remote subscriber with null selector*/ subscriber1 = ((AQjmsSession)jms_sess).createRemoteSubscriber( shipped_orders, remoteAgent, null, message.getFactory);
Note: AQ does not support the use of multiple dblink to the same destination. As a workaround, use a single database link for each destination. |
Oracle Streams Advanced Queuing allows a remote subscriber, that is a subscriber at another database, to subscribe to a topic.
Transformations can be specified when creating remote subscribers using the createRemoteSubscriber()
call. This enables propagation of messages between topics of different formats. When a message published at a topic meets the criterion of a remote subscriber, Oracle Streams Advanced Queuing automatically propagates the message to the queue/topic at the remote database specified for the remote subscriber. If a transformation is also specified, then Oracle Streams Advanced Queuing applies the transformation to the message before propagating it to the queue/topic at the remote database.
Example 14-19 Specifying Transformations for Remote Subscribers
A remote subscriber is created at the OE.OE_bookedorders_topic so that messages are automatically propagated to the WS.WS_bookedorders_topic. The transformation OE2WS is specified when creating the remote subscriber so that the messages reaching the WS_bookedorders_topic have the correct format.
Suppose that the WSOrder java class has been generated by Jpublisher to map to the Oracle object WS.WS_order
public void create_remote_sub(TopicSession jms_session) { AQjmsAgent subscriber; Topic topic; try { /* get a handle to the OE_bookedorders_topic */ topic = ((AQjmsSession)jms_session).getTopic("OE", "OE_bookedorders_topic"); subscriber = new AQjmsAgent("WShip", "WS.WS_bookedorders_topic"); ((AQjmsSession )jms_session).createRemoteSubscriber( topic, subscriber, null, WSOrder.getFactory(),"OE2WS"); } catch (JMSException ex) { System.out.println("Exception :" ex); } }
public void unsubscribe(javax.jms.Topic topic, java.lang.String subs_name) throws JMSException
This method unsubscribes a durable subscription for a local subscriber. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to unsubscribe |
subs_name | Name used to identify this subscription |
Example 14-20 Unsubscribing a Durable Subscription for a Local Subscriber
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession jms_sess; TopicSubscriber subscriber1; Topic shipped_orders; int myport = 5521; AQjmsAgent[] recipList; /* 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( "OE", "Shipped_Orders_Topic"); /* unsusbcribe "WesternShipping" from shipped_orders */ jms_sess.unsubscribe(shipped_orders, "WesternShipping");
public void unsubscribe(javax.jms.Topic topic, oracle.jms.AQjmsAgent remote_subscriber) throws JMSException
This method unsubscribes a durable subscription for a remote subscriber. It has the following parameters:
Parameter | Description |
---|---|
topic | Non-temporary topic to unsubscribe |
remote_subscriber | AQjmsAgent that refers to the remote subscriber. The address field of the AQjmsAgent cannot be null. |
Example 14-21 Unsubscribing a Durable Subscription for a Remote Subscriber
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = null; TopicSession jms_sess; Topic shipped_orders; int myport = 5521; AQjmsAgent remoteAgent; /* 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( "OE", "Shipped_Orders_Topic"); remoteAgent = new AQjmsAgent("WS", "WS.Shipped_Orders_Topic", null); /* unsubscribe the remote agent from shipped_orders */ ((AQjmsSession)jms_sess).unsubscribe(shipped_orders, remoteAgent);
public oracle.jms.AQjmsTopicReceiver createTopicReceiver( javax.jms.Topic topic, java.lang.String receiver_name, java.lang.String messageSelector) throws JMSException
This method creates a TopicReceiver
for a topic of standard JMS type messages. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
receiver_name | Name of message receiver |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
Oracle Streams Advanced Queuing allows messages to be sent to specified recipients. These receivers may or may not be subscribers of the topic. If the receiver is not a subscriber to the topic, then it receives only those messages that are explicitly addressed to it. This method must be used order to create a TopicReceiver
object for consumers that are not durable subscribers.
Example 14-22 Creating a TopicReceiver for Standard JMS Type Messages
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = ull; TopicSession jms_sess; Topic shipped_orders; int myport = 5521; TopicReceiver receiver; /* 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"); receiver = ((AQjmsSession)jms_sess).createTopicReceiver( shipped_orders, "WesternRegion", null);
public oracle.jms.AQjmsTopicReceiver createTopicReceiver( javax.jms.Topic topic, java.lang.String receiver_name, java.lang.String messageSelector, java.lang.Object payload_factory) throws JMSException
This method creates a TopicReceiver
for a topic of Oracle object type messages with selector. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
receiver_name | Name of message receiver |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
Oracle Streams Advanced Queuing allows messages to be sent to all subscribers of a topic or to specified recipients. These receivers may or may not be subscribers of the topic. If the receiver is not a subscriber to the topic, then it receives only those messages that are explicitly addressed to it. This method must be used order to create a TopicReceiver
object for consumers that are not durable subscribers.
Example 14-23 Creating a TopicReceiver for Oracle Object Type Messages
TopicConnectionFactory tc_fact = null; TopicConnection t_conn = null; TopicSession t_sess = null; TopicSession jms_sess; Topic shipped_orders; int myport = 5521; TopicReceiver receiver; /* 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"); receiver = ((AQjmsSession)jms_sess).createTopicReceiver( shipped_orders, "WesternRegion", null);
public oracle.jms.TopicBrowser createBrowser(javax.jms.Topic topic, java.lang.String cons_name, java.lang.String messageSelector) throws JMSException
This method creates a TopicBrowser
for topics with TextMessage
, StreamMessage
, ObjectMessage
, BytesMessage
, or MapMessage
message bodies. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
cons_name | Name of the durable subscriber or consumer |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Example 14-24 Creating a TopicBrowser Without a Selector
/* Create a browser without a selector */ TopicSession jms_session; TopicBrowser browser; Topic topic; browser = ((AQjmsSession) jms_session).createBrowser(topic, "SUBS1");
Example 14-25 Creating a TopicBrowser With a Specified Selector
/* Create a browser for topics with a specified selector */ TopicSession jms_session; TopicBrowser browser; Topic topic; /* create a Browser to look at messages with correlationID = RUSH */ browser = ((AQjmsSession) jms_session).createBrowser( topic, "SUBS1", "JMSCorrelationID = 'RUSH'");
public oracle.jms.TopicBrowser createBrowser(javax.jms.Topic topic, java.lang.String cons_name, java.lang.String messageSelector, boolean locked) throws JMSException
This method creates a TopicBrowser
for topics with text, stream, objects, bytes or map messages, locking messages while browsing. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
cons_name | Name of the durable subscriber or consumer |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
locked | If set to true, then messages are locked as they are browsed (similar to a SELECT for UPDATE) |
Example 14-26 Creating a TopicBrowser Without a Selector, Locking Messages While Browsing
/* Create a browser without a selector */ TopicSession jms_session; TopicBrowser browser; Topic topic; browser = ((AQjmsSession) jms_session).createBrowser( topic, "SUBS1", true);
Example 14-27 Creating a TopicBrowser With a Specified Selector, Locking Messages
/* Create a browser for topics with a specified selector */ TopicSession jms_session; TopicBrowser browser; Topic topic; /* create a Browser to look at messages with correlationID = RUSH in lock mode */ browser = ((AQjmsSession) jms_session).createBrowser( topic, "SUBS1", "JMSCorrelationID = 'RUSH'", true);
public oracle.jms.TopicBrowser createBrowser(javax.jms.Topic topic, java.lang.String cons_name, java.lang.String messageSelector, java.lang.Object payload_factory) throws JMSException
This method creates a TopicBrowser
for topics of Oracle object type messages. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
cons_name | Name of the durable subscriber or consumer |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
The CustomDatumFactory
for a particular Java class that maps to the SQL object type payload can be obtained using the getFactory
static method. Assume the topic test_topic
has payload of type SCOTT.EMPLOYEE
and the Java class that is generated by Jpublisher for this Oracle object type is called Employee
. The Employee class implements the CustomDatum
interface. The CustomDatumFactory
for this class can be obtained by using the Employee.getFactory()
method.
Example 14-28 Creating a TopicBrowser for AdtMessage Messages
/* Create a browser for a Topic with AdtMessage messages of type EMPLOYEE*/ TopicSession jms_session TopicBrowser browser; Topic test_topic; browser = ((AQjmsSession) jms_session).createBrowser( test_topic, "SUBS1", Employee.getFactory());
public oracle.jms.TopicBrowser createBrowser(javax.jms.Topic topic, java.lang.String cons_name, java.lang.String messageSelector, java.lang.Object payload_factory, boolean locked) throws JMSException
This method creates a TopicBrowser
for topics of Oracle object type messages, locking messages while browsing. It has the following parameters:
Parameter | Description |
---|---|
topic | Topic to access |
cons_name | Name of the durable subscriber or consumer |
messageSelector | Only messages with properties matching the messageSelector expression are delivered. A value of null or an empty string indicates that there is no messageSelector for the message consumer. |
payload_factory | CustomDatumFactory or ORADataFactory for the Java class that maps to the Oracle ADT |
locked | If set to true, then messages are locked as they are browsed (similar to a SELECT for UPDATE) |
Note: CustomDatum support will be deprecated in a future release. Use ORADataFactory payload factories instead. |
Example 14-29 Creating a TopicBrowser for AdtMessage Messages, Locking Messages
/* Create a browser for a Topic with AdtMessage messages of type EMPLOYEE* in lock mode/ TopicSession jms_session TopicBrowser browser; Topic test_topic; browser = ((AQjmsSession) jms_session).createBrowser( test_topic, "SUBS1", Employee.getFactory(), true);
public void purgeSeen() throws JMSException
This method browses messages using a TopicBrowser
. Use methods in java.util.Enumeration
to go through the list of messages. Use the method purgeSeen
in TopicBrowser
to purge messages that have been seen during the current browse.
Example 14-30 Creating a TopicBrowser with a Specified Selector
/* Create a browser for topics with a specified selector */ public void browse_rush_orders(TopicSession jms_session) TopicBrowser browser; Topic topic; ObjectMessage obj_message BolOrder new_order; Enumeration messages; /* get a handle to the new_orders topic */ topic = ((AQjmsSession) jms_session).getTopic("OE", "OE_bookedorders_topic"); /* create a Browser to look at RUSH orders */ browser = ((AQjmsSession) jms_session).createBrowser( topic, "SUBS1", "JMSCorrelationID = 'RUSH'"); /* Browse through the messages */ for (messages = browser.elements() ; message.hasMoreElements() ;) {obj_message = (ObjectMessage)message.nextElement();} /* Purge messages seen during this browse */ browser.purgeSeen()
Advanced Queuing User's Guide
11g Release 2 (11.2)
E11013-04
July 2011
Oracle Streams Advanced Queuing User's Guide, 11g Release 2 (11.2)
E11013-04
Copyright © 1996, 2011, Oracle and/or its affiliates. All rights reserved.
Primary Authors: Denis Raphaely, Maitreyee Chaliha
Contributing Authors: Neerja Bhatt, Charles Hall
Contributor: Longxing Deng, Stella Kister, John Leinaweaver, Qiang Liu, Anil Madan, Abhishek Saxena, James Wilson
This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle America, Inc., 500 Oracle Parkway, Redwood City, CA 94065.
This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.
This chapter describes the basic operational Java Message Service (JMS) administrative interface to Oracle Streams Advanced Queuing (AQ).
This chapter contains these topics:
Users should never directly call methods in the DBMS_AQIN
package, but they do need the EXECUTE
privilege on DBMS_AQIN
. Use the following syntax to accomplish this:
GRANT EXECUTE ON DBMS_AQIN to user;
You can register a ConnectionFactory four ways:
public static int registerConnectionFactory(java.sql.Connection connection, java.lang.String conn_name, java.lang.String hostname, java.lang.String oracle_sid, int portno, java.lang.String driver, java.lang.String type) throws JMSException
This method registers a QueueConnectionFactory
or TopicConnectionFactory through the database to a Lightweight Directory Access Protocol (LDAP) server with JDBC connection parameters. This method is static and has the following parameters:
Parameter | Description |
---|---|
connection | JDBC connection used in registration |
conn_name | Name of the connection to be registered |
hostname | Name of the host running Oracle Streams Advanced Queuing |
oracle_sid | Oracle system identifier |
portno | Port number |
driver | JDBC driver type |
type | Connection factory type (QUEUE or TOPIC ) |
The database connection passed to registerConnectionFactory
must be granted AQ_ADMINISTRATOR_ROLE
. After registration, you can look up the connection factory using Java Naming and Directory Interface (JNDI).
Example 12-1 Registering Through the Database Using JDBC Connection Parameters
String url; java.sql.connection db_conn; url = "jdbc:oracle:thin:@sun-123:1521:db1"; db_conn = DriverManager.getConnection(url, "scott", "tiger"); AQjmsFactory.registerConnectionFactory( db_conn, "queue_conn1", "sun-123", "db1", 1521, "thin", "queue");
public static int registerConnectionFactory(java.sql.Connection connection, java.lang.String conn_name, java.lang.String jdbc_url, java.util.Properties info, java.lang.String type) throws JMSException
This method registers a QueueConnectionFactory
or TopicConnectionFactory through the database with a JDBC URL to LDAP. It is static and has the following parameters:
Parameter | Description |
---|---|
connection | JDBC connection used in registration |
conn_name | Name of the connection to be registered |
jdbc_url | URL to connect to |
info | Properties information |
portno | Port number |
type | Connection factory type (QUEUE or TOPIC ) |
The database connection passed to registerConnectionFactory
must be granted AQ_ADMINISTRATOR_ROLE
. After registration, you can look up the connection factory using JNDI.
public static int registerConnectionFactory(java.util.Hashtable env, java.lang.String conn_name, java.lang.String hostname, java.lang.String oracle_sid, int portno, java.lang.String driver, java.lang.String type) throws JMSException
This method registers a QueueConnectionFactory
or TopicConnectionFactory through LDAP with JDBC connection parameters to LDAP. It is static and has the following parameters:
Parameter | Description |
---|---|
env | Environment of LDAP connection |
conn_name | Name of the connection to be registered |
hostname | Name of the host running Oracle Streams Advanced Queuing |
oracle_sid | Oracle system identifier |
portno | Port number |
driver | JDBC driver type |
type | Connection factory type (QUEUE or TOPIC ) |
The hash table passed to registerConnectionFactory()
must contain all the information to establish a valid connection to the LDAP server. Furthermore, the connection must have write access to the connection factory entries in the LDAP server (which requires the LDAP user to be either the database itself or be granted GLOBAL_AQ_USER_ROLE
). After registration, look up the connection factory using JNDI.
Example 12-3 Registering Through LDAP Using JDBC Connection Parameters
Hashtable env = new Hashtable(5, 0.75f); /* the following statements set in hashtable env: * service provider package * the URL of the ldap server * the distinguished name of the database server * the authentication method (simple) * the LDAP username * the LDAP user password */ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://sun-456:389"); env.put("searchbase", "cn=db1,cn=Oraclecontext,cn=acme,cn=com"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=db1aqadmin,cn=acme,cn=com"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); AQjmsFactory.registerConnectionFactory(env, "queue_conn1", "sun-123", "db1", 1521, "thin", "queue");
public static int registerConnectionFactory(java.util.Hashtable env, java.lang.String conn_name, java.lang.String jdbc_url, java.util.Properties info, java.lang.String type) throws JMSException
This method registers a QueueConnectionFactory
or TopicConnectionFactory through LDAP with JDBC connection parameters to LDAP. It is static and has the following parameters:
Parameter | Description |
---|---|
env | Environment of LDAP connection |
conn_name | Name of the connection to be registered |
jdbc_url | URL to connect to |
info | Properties information |
type | Connection factory type (QUEUE or TOPIC ) |
The hash table passed to registerConnectionFactory()
must contain all the information to establish a valid connection to the LDAP server. Furthermore, the connection must have write access to the connection factory entries in the LDAP server (which requires the LDAP user to be either the database itself or be granted GLOBAL_AQ_USER_ROLE)
. After registration, look up the connection factory using JNDI.
Example 12-4 Registering Through LDAP Using a JDBC URL
String url; Hashtable env = new Hashtable(5, 0.75f); /* the following statements set in hashtable env: * service provider package * the URL of the ldap server * the distinguished name of the database server * the authentication method (simple) * the LDAP username * the LDAP user password */ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://sun-456:389"); env.put("searchbase", "cn=db1,cn=Oraclecontext,cn=acme,cn=com"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=db1aqadmin,cn=acme,cn=com"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); url = "jdbc:oracle:thin:@sun-123:1521:db1"; AQjmsFactory.registerConnectionFactory(env, "topic_conn1", url, null, "topic");
You can unregister a queue/topic ConnectionFactory
in LDAP two ways:
public static int unregisterConnectionFactory(java.sql.Connection connection, java.lang.String conn_name) throws JMSException
This method unregisters a QueueConnectionFactory
or TopicConnectionFactory
in LDAP. It is static and has the following parameters:
Parameter | Description |
---|---|
connection | JDBC connection used in registration |
conn_name | Name of the connection to be registered |
The database connection passed to unregisterConnectionFactory()
must be granted AQ_ADMINISTRATOR_ROLE
.
public static int unregisterConnectionFactory(java.util.Hashtable env, java.lang.String conn_name) throws JMSException
This method unregisters a QueueConnectionFactory
or TopicConnectionFactory in LDAP. It is static and has the following parameters:
Parameter | Description |
---|---|
env | Environment of LDAP connection |
conn_name | Name of the connection to be registered |
The hash table passed to unregisterConnectionFactory()
must contain all the information to establish a valid connection to the LDAP server. Furthermore, the connection must have write access to the connection factory entries in the LDAP server (which requires the LDAP user to be either the database itself or be granted GLOBAL_AQ_USER_ROLE
).
Example 12-6 Unregistering Through LDAP
Hashtable env = new Hashtable(5, 0.75f); /* the following statements set in hashtable env: * service provider package * the distinguished name of the database server * the authentication method (simple) * the LDAP username * the LDAP user password */ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://sun-456:389"); env.put("searchbase", "cn=db1,cn=Oraclecontext,cn=acme,cn=com"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=db1aqadmin,cn=acme,cn=com"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); url = "jdbc:oracle:thin:@sun-123:1521:db1"; AQjmsFactory.unregisterConnectionFactory(env, "queue_conn1");
This section contains these topics:
Getting a QueueConnectionFactory with JDBC Connection Parameters
Getting a TopicConnectionFactory with JDBC Connection Parameters
Getting a QueueConnectionFactory or TopicConnectionFactory in LDAP
public static javax.jms.QueueConnectionFactory getQueueConnectionFactory( java.lang.String jdbc_url, java.util.Properties info) throws JMSException
This method gets a QueueConnectionFactory
with JDBC URL. It is static and has the following parameters:
Parameter | Description |
---|---|
jdbc_url | URL to connect to |
info | Properties information |
public static javax.jms.QueueConnectionFactory getQueueConnectionFactory( java.lang.String hostname, java.lang.String oracle_sid, int portno, java.lang.String driver) throws JMSException
This method gets a QueueConnectionFactory
with JDBC connection parameters. It is static and has the following parameters:
Parameter | Description |
---|---|
hostname | Name of the host running Oracle Streams Advanced Queuing |
oracle_sid | Oracle system identifier |
portno | Port number |
driver | JDBC driver type |
public static javax.jms.QueueConnectionFactory getQueueConnectionFactory( java.lang.String jdbc_url, java.util.Properties info) throws JMSException
This method ge ts a TopicConnectionFactory
with a JDBC URL. It is static and has the following parameters:
Parameter | Description |
---|---|
jdbc_url | URL to connect to |
info | Properties information |
public static javax.jms.TopicConnectionFactory getTopicConnectionFactory( java.lang.String hostname, java.lang.String oracle_sid, int portno, java.lang.String driver) throws JMSException
This method gets a TopicConnectionFactory
with JDBC connection parameters. It is static and has the following parameters:
Parameter | Description |
---|---|
hostname | Name of the host running Oracle Streams Advanced Queuing |
oracle_sid | Oracle system identifier |
portno | Port number |
driver | JDBC driver type |
This method gets a QueueConnectionFactory
or TopicConnectionFactory
from LDAP.
Example 12-11 Getting a QueueConnectionFactory or TopicConnectionFactory in LDAP
Hashtable env = new Hashtable(5, 0.75f); DirContext ctx; queueConnectionFactory qc_fact; /* the following statements set in hashtable env: * service provider package * the URL of the ldap server * the distinguished name of the database server * the authentication method (simple) * the LDAP username * the LDAP user password */ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://sun-456:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=db1aquser1,cn=acme,cn=com"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); ctx = new InitialDirContext(env); ctx = (DirContext)ctx.lookup("cn=OracleDBConnections,cn=db1,cn=Oraclecontext,cn=acme,cn=com"); qc_fact = (queueConnectionFactory)ctx.lookup("cn=queue_conn1");
This method gets a queue or topic from LDAP.
Example 12-12 Getting a Queue or Topic in LDAP
Hashtable env = new Hashtable(5, 0.75f); DirContext ctx; topic topic_1; /* the following statements set in hashtable env: * service provider package * the URL of the ldap server * the distinguished name of the database server * the authentication method (simple) * the LDAP username * the LDAP user password */ env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://sun-456:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "cn=db1aquser1,cn=acme,cn=com"); env.put(Context.SECURITY_CREDENTIALS, "welcome"); ctx = new InitialDirContext(env); ctx = (DirContext)ctx.lookup("cn=OracleDBQueues,cn=db1,cn=Oraclecontext,cn=acme,cn=com"); topic_1 = (topic)ctx.lookup("cn=topic_1");
public oracle.AQ.AQQueueTable createQueueTable( java.lang.String owner, java.lang.String name, oracle.AQ.AQQueueTableProperty property) throws JMSException
This method creates a queue table. It has the following parameters:
Parameter | Description |
---|---|
owner | Queue table owner (schema) |
name | Queue table name |
property | Queue table properties |
If the queue table is used to hold queues, then the queue table must not be multiconsumer enabled (default). If the queue table is used to hold topics, then the queue table must be multiconsumer enabled.
CLOB, BLOB, and BFILE objects are valid attributes for an Oracle Streams Advanced Queuing object type load. However, only CLOB and BLOB can be propagated using Oracle Streams Advanced Queuing propagation in Oracle8i and after.
public oracle.AQ.AQQueueTable getQueueTable(java.lang.String owner, java.lang.String name) throws JMSException
This method gets a queue table. It has the following parameters:
Parameter | Description |
---|---|
owner | Queue table owner (schema) |
name | Queue table name |
If the caller that opened the connection is not the owner of the queue table, then the caller must have Oracle Streams Advanced Queuing enqueue/dequeue privileges on queues/topics in the queue table. Otherwise the queue table is not returned.
This section contains these topics:
public javax.jms.Queue createQueue( oracle.AQ.AQQueueTable q_table, java.lang.String queue_name, oracle.jms.AQjmsDestinationProperty dest_property) throws JMSException
This method creates a queue in a specified queue table. It has the following parameters:
Parameter | Description |
---|---|
q_table | Queue table in which the queue is to be created. The queue table must be single-consumer. |
queue_name | Name of the queue to be created |
dest_property | Queue properties |
This method is specific to OJMS. You cannot use standard Java javax.jms.Session
objects with it. Instead, you must cast the standard type to the OJMS concrete class oracle.jms.AQjmsSession
.
public javax.jms.Topic createTopic( oracle.AQ.AQQueueTable q_table, java.lang.String topic_name, oracle.jms.AQjmsDestinationProperty dest_property) throws JMSException
This method creates a topic in the publish/subscribe model. It has the following parameters:
Parameter | Description |
---|---|
q_table | Queue table in which the queue is to be created. The queue table must be multiconsumer. |
queue_name | Name of the queue to be created |
dest_property | Queue properties |
This method is specific to OJMS. You cannot use standard Java javax.jms.Session
objects with it. Instead, you must cast the standard type to the OJMS concrete class oracle.jms.AQjmsSession
.
Example 12-16 Creating a Publish/Subscribe Topic
TopicSession t_sess; AQQueueTable q_table; AqjmsDestinationProperty dest_prop; Topic topic; topic = ((AQjmsSessa)t_sess).createTopic(q_table, "jms_t1", dest_prop);
In Example 12-17, if an order cannot be filled because of insufficient inventory, then the transaction processing the order is terminated. The bookedorders
topic is set up with max_retries
= 4 and retry_delay
= 12 hours.Thus, if an order is not filled up in two days, then it is moved to an exception queue.
Example 12-17 Specifying Max Retries and Max Delays in Messages
public BolOrder process_booked_order(TopicSession jms_session) { Topic topic; TopicSubscriber tsubs; ObjectMessage obj_message; BolCustomer customer; BolOrder booked_order = null; String country; int i = 0; try { /* get a handle to the OE_bookedorders_topic */ topic = ((AQjmsSession)jms_session).getTopic("WS", "WS_bookedorders_topic"); /* Create local subscriber - to track messages for Western Region */ tsubs = jms_session.createDurableSubscriber(topic, "SUBS1", "Region = 'Western' ", false); /* wait for a message to show up in the topic */ obj_message = (ObjectMessage)tsubs.receive(10); booked_order = (BolOrder)obj_message.getObject(); customer = booked_order.getCustomer(); country = customer.getCountry(); if (country == "US") { jms_session.commit(); } else { jms_session.rollback(); booked_order = null; } }catch (JMSException ex) { System.out.println("Exception " + ex) ;} return booked_order; }
This section contains these topics:
public void grantSystemPrivilege(java.lang.String privilege, java.lang.String grantee, boolean admin_option) throws JMSException
This method grants Oracle Streams Advanced Queuing system privileges to a user or role.
Parameter | Description |
---|---|
privilege | ENQUEUE_ANY , DEQUEUE_ANY or MANAGE_ANY |
grantee | Grantee (user, role, or PUBLIC ) |
admin_option | If this is set to true, then the grantee is allowed to use this procedure to grant the system privilege to other users or roles |
Initially only SYS
and SYSTEM
can use this procedure successfully. Users granted the ENQUEUE_ANY
privilege are allowed to enqueue messages to any queues in the database. Users granted the DEQUEUE_ANY
privilege are allowed to dequeue messages from any queues in the database. Users granted the MANAGE_ANY
privilege are allowed to run DBMS_AQADM
calls on any schemas in the database.
public void revokeSystemPrivilege(java.lang.String privilege, java.lang.String grantee) throws JMSException
This method revokes Oracle Streams Advanced Queuing system privileges from a user or role. It has the following parameters:
Parameter | Description |
---|---|
privilege | ENQUEUE_ANY , DEQUEUE_ANY or MANAGE_ANY |
grantee | Grantee (user, role, or PUBLIC ) |
Users granted the ENQUEUE_ANY
privilege are allowed to enqueue messages to any queues in the database. Users granted the DEQUEUE_ANY
privilege are allowed to dequeue messages from any queues in the database. Users granted the MANAGE_ANY
privilege are allowed to run DBMS_AQADM
calls on any schemas in the database.
public void grantTopicPrivilege(javax.jms.Session session, java.lang.String privilege, java.lang.String grantee, boolean grant_option) throws JMSException
This method grants a topic privilege in the publish/subscribe model. Initially only the queue table owner can use this procedure to grant privileges on the topic. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
privilege | ENQUEUE , DEQUEUE, or ALL (ALL means both.) |
grantee | Grantee (user, role, or PUBLIC ) |
grant_option | If this is set to true, then the grantee is allowed to use this procedure to grant the system privilege to other users or roles |
public void revokeTopicPrivilege(javax.jms.Session session, java.lang.String privilege, java.lang.String grantee) throws JMSException
This method revokes a topic privilege in the publish/subscribe model. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
privilege | ENQUEUE , DEQUEUE, or ALL (ALL means both.) |
grantee | Revoked grantee (user, role, or PUBLIC ) |
public void grantQueuePrivilege(javax.jms.Session session, java.lang.String privilege, java.lang.String grantee, boolean grant_option) throws JMSException
This method grants a queue privilege in the point-to-point model. Initially only the queue table owner can use this procedure to grant privileges on the queue. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
privilege | ENQUEUE , DEQUEUE, or ALL (ALL means both.) |
grantee | Grantee (user, role, or PUBLIC ) |
grant_option | If this is set to true, then the grantee is allowed to use this procedure to grant the system privilege to other users or roles |
public void revokeQueuePrivilege(javax.jms.Session session, java.lang.String privilege, java.lang.String grantee) throws JMSException
This method revokes queue privileges in the point-to-point model. Initially only the queue table owner can use this procedure to grant privileges on the queue. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
privilege | ENQUEUE , DEQUEUE, or ALL (ALL means both.) |
grantee | Revoked grantee (user, role, or PUBLIC ) |
To revoke a privilege, the revoker must be the original grantor of the privilege. Privileges propagated through the GRANT
option are revoked if the grantor privilege is also revoked.
This section contains these topics:
public void start(javax.jms.Session session, boolean enqueue, boolean dequeue) throws JMSException
This method starts a destination. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
enqueue | If set to TRUE , then enqueue is enabled |
dequeue | If set to TRUE , then dequeue is enabled |
public void stop(javax.jms.Session session, boolean enqueue, boolean dequeue, boolean wait) throws JMSException
This method stops a destination. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
enqueue | If set to TRUE , then enqueue is disabled |
dequeue | If set to TRUE , then dequeue is disabled |
wait | If set to true, then pending transactions on the queue/topic are allowed to complete before the destination is stopped |
public void alter(javax.jms.Session session, oracle.jms.AQjmsDestinationProperty dest_property) throws JMSException
This method alters a destination. It has the following properties:
Parameter | Description |
---|---|
session | JMS session |
dest_property | New properties of the queue or topic |
This section contains these topics:
public void schedulePropagation(javax.jms.Session session, java.lang.String destination, java.util.Date start_time, java.lang.Double duration, java.lang.String next_time, java.lang.Double latency) throws JMSException
This method schedules a propagation. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
destination | Database link of the remote database for which propagation is being scheduled. A null string means that propagation is scheduled for all subscribers in the database of the topic. |
start_time | Time propagation starts |
duration | Duration of propagation |
next_time | Next time propagation starts |
latency | Latency in seconds that can be tolerated. Latency is the difference between the time a message was enqueued and the time it was propagated. |
If a message has multiple recipients at the same destination in either the same or different queues, then it is propagated to all of them at the same time.
public void enablePropagationSchedule(javax.jms.Session session, java.lang.String destination) throws JMSException
This method enables a propagation schedule. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
destination | Database link of the destination database. A null string means that propagation is to the local database. |
public void alterPropagationSchedule(javax.jms.Session session, java.lang.String destination, java.lang.Double duration, java.lang.String next_time, java.lang.Double latency) throws JMSException
This method alters a propagation schedule. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
destination | Database link of the remote database for which propagation is being scheduled. A null string means that propagation is scheduled for all subscribers in the database of the topic. |
duration | Duration of propagation |
next_time | Next time propagation starts |
latency | Latency in seconds that can be tolerated. Latency is the difference between the time a message was enqueued and the time it was propagated. |
public void disablePropagationSchedule(javax.jms.Session session, java.lang.String destination) throws JMSException
This method disables a propagation schedule. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
destination | Database link of the destination database. A null string means that propagation is to the local database. |
public void unschedulePropagation(javax.jms.Session session, java.lang.String destination) throws JMSException
This method unschedules a previously scheduled propagation. It has the following parameters:
Parameter | Description |
---|---|
session | JMS session |
destination | Database link of the destination database. A null string means that propagation is to the local database. |
This chapter describes the Oracle Streams Advanced Queuing (AQ) basic components.
This chapter contains the following topics:
Enumerated Constants in the Oracle Streams Advanced Queuing Administrative Interface
Enumerated Constants in the Oracle Streams Advanced Queuing Operational Interface
object_name := VARCHAR2 object_name := [schema_name.]name
This component names database objects. This naming convention applies to queues, queue tables, and object types.
Names for objects are specified by an optional schema name and a name. If the schema name is not specified, then the current schema is assumed. The name must follow the reserved character guidelines in Oracle Database SQL Language Reference. The schema name, agent name, and the object type name can each be up to 30 bytes long. However, queue names and queue table names can be a maximum of 24 bytes.
type_name := VARCHAR2
type_name := object_type | "RAW"
This component defines queue types. The maximum number of attributes in the object type is limited to 900.
To store payloads of type RAW
, Oracle Streams Advanced Queuing creates a queue table with a LOB column as the payload repository. The size of the payload is limited to 32K bytes of data. Because LOB
columns are used for storing RAW
payload, the Oracle Streams Advanced Queuing administrator can choose the LOB
tablespace and configure the LOB
storage by constructing a LOB
storage string in the storage_clause
parameter during queue table creation time.
Note: Payloads containing LOBs require users to grant explicitSelect , Insert and Update privileges on the queue table for doing enqueues and dequeues. |
TYPE AQ$_AGENT IS OBJECT ( name VARCHAR2(30), address VARCHAR2(1024), protocol NUMBER);
This component identifies a producer or a consumer of a message.
All consumers that are added as subscribers to a multiconsumer queue must have unique values for the AQ$_AGENT
parameters. Two subscribers cannot have the same values for the NAME
, ADDRESS,
and PROTOCOL
attributes for the AQ$_AGENT
type. At least one of the three attributes must be different for two subscribers.
You can add subscribers by repeatedly using the DBMS_AQADM.ADD_SUBSCRIBER
procedure up to a maximum of 1024 subscribers for a multiconsumer queue.
This type has three attributes:
name
This attribute specifies the name of a producer or consumer of a message. It can be the name of an application or a name assigned by an application. A queue can itself be an agent, enqueuing or dequeuing from another queue. The name must follow the reserved character guidelines in Oracle Database SQL Language Reference.
address
This attribute is interpreted in the context of protocol
. If protocol
is 0 (default), then address
is of the form [schema.]queue[@dblink]
.
protocol
This attribute specifies the protocol to interpret the address and propagate the message. The default value is 0.
TYPE AQ$_RECIPIENT_LIST_T IS TABLE OF aq$_agent INDEX BY BINARY_INTEGER;
This component identifies the list of agents that receive a message.
TYPE AQ$_AGENT_LIST_T IS TABLE OF aq$_agent INDEX BY BINARY INTEGER;
This component identifies the list of agents for DBMS_AQ.LISTEN
to listen for.
TYPE AQ$_SUBSCRIBER_LIST_T IS TABLE OF aq$_agent INDEX BY BINARY INTEGER;
This component identifies the list of subscribers that subscribe to this queue.
TYPE AQ$_REG_INFO_LIST AS VARRAY(1024) OF sys.aq$_reg_info;
This component identifies the list of registrations to a queue.
TYPE AQ$_POST_INFO_LIST AS VARRAY(1024) OF sys.aq$_post_info;
This component identifies the list of anonymous subscriptions to which messages are posted.
TYPE SYS.AQ$_REG_INFO IS OBJECT ( name VARCHAR2(128), namespace NUMBER, callback VARCHAR2(4000), context RAW(2000) DEFAULT NULL, qosflags NUMBER, timeout NUMBER ntfn_grouping_class NUMBER, ntfn_grouping_value NUMBER DEFAULT 600, ntfn_grouping_type NUMBER, ntfn_grouping_start_time TIMESTAMP WITH TIME ZONE, ntfn_grouping_repeat_count NUMBER);
This component identifies a producer or a consumer of a message. Its attributes are described in the following list. Attributes qosflags
and timeout
are part of Oracle Streams Advanced Queuing 10g Release 2 (10.2) notification enhancements.
Table 2-1 AQ$_REG_INFO Type Attributes
Attribute | Description |
---|---|
|
Specifies the name of the subscription. The subscription name is of the form |
|
Specifies the namespace of the subscription. To receive notification from Oracle Streams AQ queues, the namespace must be |
|
Specifies the action to be performed on message notification. For HTTP notifications, use |
|
Specifies the context that is to be passed to the callback function |
|
Can be set to one or more of the following values to specify the notification quality of service:
|
|
Currently, only the following flag can be set to specify criterion for grouping. The default value will be 0. If
|
|
Time-period of grouping notifications specified in seconds, meaning the time after which grouping notification would be sent periodically until |
|
|
|
Notification grouping start time. Notification grouping can start from a user-specified time that should a valid timestamp with time zone. If |
|
Grouping notifications will be sent as many times as specified by the notification grouping repeat count and after that revert to regular notifications. The ntfn_grouping_repeat_count, if not specified, will default to
|
TYPE SYS.AQ$_DESCRIPTOR IS OBJECT ( queue_name VARCHAR2(61), consumer_name VARCHAR2(30), msg_id RAW(16), msg_prop MSG_PROP_T, gen_desc AQ$_NTFN_DESCRIPTOR, msgid_array SYS.AQ$_NTFN_MSGID_ARRAY, ntfnsRecdInGrp NUMBER);
This component specifies the Oracle Streams Advanced Queuing descriptor received by Oracle Streams Advanced Queuing PL/SQL callbacks upon notification. It has the following attributes:
Table 2-2 AQ$_DESCRIPTOR Attributes
Attribute | Description |
---|---|
|
Name of the queue in which the message was enqueued which resulted in the notification |
|
Name of the consumer for the multiconsumer queue |
|
Identification number of the message |
|
Message properties specified by the |
|
Indicates the timeout specifications |
|
Group notification message ID list |
|
Notifications received in group |
The message properties type msg_prop_t
has the following components:
TYPE AQ$_MSG_PROP_T IS OBJECT( priority number, delay number, expiration number, correlation varchar2(128), attempts number, recipent_list aq$_recipient_list_t, exception_queue varchar2(51), enqueue_time date, state number, sender_id aq$_agent, original_misgid raw(16), delivery_mode number);
The timeout specifications type AQ$_NTFN_DESCRIPTOR
has a single component:
TYPE AQ$_NTFN_DESCRIPTOR IS OBJECT( NTFN_FLAGS number);
NTFN_FLAGS
is set to 1
if the notifications are already removed after a stipulated timeout; otherwise the value is 0
.
TYPE SYS.AQ$_POST_INFO IS OBJECT ( name VARCHAR2(128), namespace NUMBER, payload RAW(2000));
This component specifies anonymous subscriptions to which you want to post messages. It has three attributes:
name
This attribute specifies the name of the anonymous subscription to which you want to post.
namespace
This attribute specifies the namespace of the anonymous subscription. To receive notifications from other applications using DBMS_AQ.POST
or OCISubscriptionPost()
, the namespace must be DBMS_AQ.NAMESPACE_ANONYMOUS
.
payload
This attribute specifies the payload to be posted to the anonymous subscription. The default is NULL
.
TYPE SYS.AQ$_NTFN_MSGID_ARRAY AS VARRAY(1073741824)OF RAW(16);
This component is for storing grouping notification data for AQ namespace, value 230 which is the max varray size.
When enumerated constants such as INFINITE
, TRANSACTIONAL
, and NORMAL_QUEUE
are selected as values, the symbol must be specified with the scope of the packages defining it. All types associated with the administrative interfaces must be prepended with DBMS_AQADM
. For example:
DBMS_AQADM.NORMAL_QUEUE
Table 2-3 lists the enumerated constants in the Oracle Streams Advanced Queuing administrative interface.
Table 2-3 Enumerated Constants in the Oracle Streams Advanced Queuing Administrative Interface
Parameter | Options |
---|---|
| |
| |
| |
|
|
Note: Nonpersistent queues are deprecated in Oracle Streams Advanced Queuing 10g Release 2 (10.2). Oracle recommends that you use buffered messaging instead. |
When using enumerated constants such as BROWSE
, LOCKED
, and REMOVE
, the PL/SQL constants must be specified with the scope of the packages defining them. All types associated with the operational interfaces must be prepended with DBMS_AQ
. For example:
DBMS_AQ.BROWSE
Table 2-4 lists the enumerated constants in the Oracle Streams Advanced Queuing operational interface.
Table 2-4 Enumerated Constants in the Oracle Streams Advanced Queuing Operational Interface
Parameter | Options |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
A number of Streams AQ or Streams tasks are executed in the background. These include converting messages with DELAY
specified into the READY
state, expiring messages, moving messages to exception queues, spilling and recovering of buffered messages, and similar operations.
These are executed by a set of AQ background process. These include a coordinator process, name QMNC (link), which dynamically spawns subordinate processes Qxx
as needed. The number of subordinate processes is determined automatically and tuned constantly.
It is no longer necessary to set AQ_TM_PROCESSES
when Oracle Streams AQ or Streams is used. If a value is specified, that value is taken into account when starting the Qxx
processes. However, the number of Qxx processes can be different from what was specified by AQ_TM_PROCESSES
.
QMNC only runs when you use queues and create new queues. It affects Streams Replication and Messaging users.
No separate API is needed to disable or enable the background processes. This is controlled by setting AQ_TM_PROCESSES
to zero or nonzero. Oracle recommends, however, that you leave the AQ_TM_PROCESSES
parameter unspecified and let the system autotune.
Note: If you want to disable the Queue Monitor Coordinator, then you must setAQ_TM_PROCESSES = 0 in your pfile or spfile . Oracle strongly recommends that you do NOT set AQ_TM_PROCESSES = 0 . If you are using Oracle Streams, then setting this parameter to zero (which Oracle Database respects no matter what) can cause serious problems. |
Propagation and PL/SQL notifications are handled by job queue (Jnnn) processes. The parameter JOB_QUEUE_PROCESSES
no longer needs to be specified. The database scheduler automatically starts the job queue processes that are needed for the propagation and notification jobs.
You can access Oracle Streams Advanced Queuing (AQ) over the Internet by using Simple Object Access Protocol (SOAP). Internet Data Access Presentation (IDAP) is the SOAP specification for Oracle Streams Advanced Queuing operations. IDAP defines XML message structure for the body of the SOAP request. An IDAP-structured message is transmitted over the Internet using HTTP.
Users can register for notifications using the IDAP interface.
This chapter contains these topics:
See Also:
|
This section contains these topics:
Oracle Streams Advanced Queuing Internet Operations Architecture
Configuring the Web Server to Authenticate Users Sending POST Requests
Oracle Streams Advanced Queuing Servlet Responses Using HTTP
Oracle Streams Advanced Queuing Propagation Using HTTP and HTTPS
Figure 6-1 shows the architecture for performing Oracle Streams Advanced Queuing operations over HTTP. The major components are:
Oracle Streams Advanced Queuing client program
Web server/servlet runner hosting the Oracle Streams Advanced Queuing servlet
Oracle Database server
A Web browser or any other HTTP client can serve as an Oracle Streams Advanced Queuing client program, sending XML messages conforming to IDAP to the Oracle Streams Advanced Queuing servlet, which interprets the incoming XML messages. The Oracle Streams Advanced Queuing servlet connects to the Oracle Database server and performs operations on user queues.
Figure 6-1 Architecture for Performing Oracle Streams Advanced Queuing Operations Using HTTP
Oracle Streams Advanced Queuing supports messages of three types: RAW, Oracle object, and Java Message Service (JMS). All these message types can be accessed using SOAP and Web services. If the queue holds messages in RAW, Oracle object, or JMS format, then XML payloads are transformed to the appropriate internal format during enqueue and stored in the queue. During dequeue, when messages are obtained from queues containing messages in any of the preceding formats, they are converted to XML before being sent to the client.
The message payload type depends on the queue type on which the operation is being performed:
The contents of RAW queues are raw bytes. You must supply the hex representation of the message payload in the XML message. For example, <raw>023f4523</raw>
.
For Oracle object type queues that are not JMS queues (that is, they are not type AQ$_JMS_*
), the type of the payload depends on the type specified while creating the queue table that holds the queue. The content of the XML elements must map to the attributes of the object type of the queue table.
For queues with JMS types (that is, those with payloads of type AQ$_JMS_*
), there are four XML elements, depending on the JMS type. IDAP supports queues or topics with the following JMS types:
TextMessage
MapMessage
BytesMessage
ObjectMessage
JMS queues with payload type StreamMessage
are not supported through IDAP.
After the servlet is installed, the Web server must be configured to authenticate all users that send POST
requests to the Oracle Streams Advanced Queuing servlet. The Oracle Streams Advanced Queuing servlet allows only authenticated users to access the servlet. If the user is not authenticated, then an error is returned by the servlet.
The Web server can be configured in multiple ways to restrict access. Some of the common techniques are basic authentication (username/password) over SSL and client certificates. Consult your Web server documentation to see how you can restrict access to servlets.
In the context of the Oracle Streams Advanced Queuing servlet, the username that is used to connect to the Web server is known as the Oracle Streams Advanced Queuing HTTP agent or Oracle Streams Advanced Queuing Internet user.
An Oracle Streams Advanced Queuing client begins a request to the Oracle Streams Advanced Queuing servlet using HTTP by opening a connection to the server. The client logs in to the server using HTTP basic authentication (with or without SSL) or SSL certificate-based client authentication. The client constructs an XML message representing the send, publish, receive or register request.
The client sends an HTTP POST
to the servlet at the remote server.
See Also: Table 1-3, "Oracle Streams Advanced Queuing XML Demonstrations" for the locations of AQ XML demonstrations illustratingPOST requests using HTTP |
After a client is authenticated and connects to the Oracle Streams Advanced Queuing servlet, an HTTP session is created on behalf of the user. The first request in the session also implicitly starts a new database transaction. This transaction remains open until it is explicitly committed or terminated. The responses from the servlet includes the session ID in the HTTP headers as cookies.
If the client wishes to continue work in the same transaction, then it must include this HTTP header containing the session ID cookie in subsequent requests. This is automatically accomplished by most Web browsers. However, if the client is using a Java or C client to post requests, then this must be accomplished programmatically.
See Also: Table 1-3, "Oracle Streams Advanced Queuing XML Demonstrations" for the locations of AQ XML demonstrations illustrating a Java program used to post requests as part of the same session |
An explicit commit or rollback must be applied to end the transaction. The commit or rollback requests can also be included as part of other Oracle Streams Advanced Queuing operations.
The server accepts the client HTTP(S) connection and authenticates the user (Oracle Streams Advanced Queuing agent) specified by the client. The server receives the POST
request and invokes the Oracle Streams Advanced Queuing servlet.
If this is the first request from this client, then a new HTTP session is created. The XML message is parsed and its contents are validated. If a session ID is passed by the client in the HTTP headers, then this operation is performed in the context of that session.
The servlet determines which object (queue/topic) the agent is trying to perform operations on. The servlet looks through the list of database users that map to this Oracle Streams Advanced Queuing agent. If any one of these users has privileges to access the queue/topic specified in the request, then the Oracle Streams Advanced Queuing servlet superuser creates a session on behalf of this user.
If no transaction is active in the HTTP session, then a new database transaction is started. Subsequent requests in the session are part of the same transaction until an explicit COMMIT
or ROLLBACK
request is made. The effects of the transaction are visible only after it is committed. If the transaction remains inactive for 120 seconds, then it is automatically terminated.
The requested operation is performed. The response is formatted as an XML message and sent back the client. The response also includes the session ID in the HTTP headers as a cookie.
You can propagate over HTTP and HTTPS (HTTP over SSL) instead of Oracle Net Services. HTTP, unlike Oracle Net Services, is easy to configure for firewalls. The background process doing propagation pushes messages to an Oracle Streams Advanced Queuing servlet that enqueues them into the destination database, as shown in Figure 6-2.
Figure 6-2 HTTP Oracle Streams Advanced Queuing Propagation
You can set up any application to use Oracle Streams Advanced Queuing HTTP propagation without any change to the existing code. An application using Oracle Streams Advanced Queuing HTTP propagation can easily switch back to Net Services propagation just by re-creating the database link with a Net Services connection string, without any other changes.
Follow these steps to deploy the AQ XML servlet using OC4J:
For JDK1.2.x or JDK1.3.x, include the following in your CLASSPATH
:
ORACLE_HOME/jdbc/lib/classes12.zip ORACLE_HOME/jdbc/lib/nls_charset12.zip ORACLE_HOME/jlib/javax-ssl-1_1.jar ORACLE_HOME/jlib/jndi.jar ORACLE_HOME/jlib/jssl-1_1.jar ORACLE_HOME/jlib/jta.jar ORACLE_HOME/jlib/orai18n.jar ORACLE_HOME/jlib/orai18n-collation.jar ORACLE_HOME/jlib/orai18n-mapping.jar ORACLE_HOME/jlib/orai18n-utility.jar ORACLE_HOME/lib/http_client.jar ORACLE_HOME/lib/lclasses12.zip ORACLE_HOME/lib/servlet.jar ORACLE_HOME/lib/xmlparserv2.jar ORACLE_HOME/lib/xschema.jar ORACLE_HOME/lib/xsu12.jar ORACLE_HOME/rdbms/jlib/aqapi.jar ORACLE_HOME/rdbms/jlib/aqxml.jar ORACLE_HOME/rdbms/jlib/jmscommon.jar ORACLE_HOME/rdbms/jlib/xdb.jar ORACLE_HOME/rdbms/jlib/xsu12.jar
For JDK1.4.x, include the following in your CLASSPATH
:
ORACLE_HOME/jdbc/lib/ojdbc14.jar ORACLE_HOME/jlib/javax-ssl-1_1.jar ORACLE_HOME/jlib/jndi.jar ORACLE_HOME/jlib/jssl-1_1.jar ORACLE_HOME/jlib/jta.jar ORACLE_HOME/jlib/orai18n.jar ORACLE_HOME/jlib/orai18n-collation.jar ORACLE_HOME/jlib/orai18n-mapping.jar ORACLE_HOME/jlib/orai18n-utility.jar ORACLE_HOME/lib/http_client.jar ORACLE_HOME/lib/lclasses12.zip ORACLE_HOME/lib/servlet.jar ORACLE_HOME/lib/xmlparserv2.jar ORACLE_HOME/lib/xschema.jar ORACLE_HOME/lib/xsu12.jar ORACLE_HOME/rdbms/jlib/aqapi.jar ORACLE_HOME/rdbms/jlib/aqxml.jar ORACLE_HOME/rdbms/jlib/jmscommon.jar ORACLE_HOME/rdbms/jlib/xdb.jar
Note: http_client.jar , jssl-1_1.jar , and javax-ssl-1_1.jar are required by HTTPClient used in AQHttp.java and AQHttpRq.java . |
Compile AQHttpRq.java
:
cd ORACLE_HOME/rdbms/demo
javac AQHttpRq.java AQHttp.java
Set the following database initialization parameters to the indicated values:
job_queue_processes=2 compatible=10.2.0
Restart the database and listener.
Set up queues and authenticate users for restricted access.
See Also: aqxmlREADME.txt and aqxmldmo.sql in ORACLE_HOME /rdbms/demo for additional information. |
Deploy the servlet and start the OC4J instance:
cd ORACLE_HOME/bin
sh aqxmlctl deploy
sh aqxmlctl start
Note: Usesh aqxmlctl stop to stop the OC4J instance. The deploy servlet and start OC4J instance steps might have been done during your Oracle Database installation. You can verify this in the following steps. |
Check the status of the servlet and information on the protocol and port number used for deploying the servlet in the following files:
ORACLE_HOME/rdbms/demo/aqxml.ini ORACLE_HOME/oc4j/j2ee/OC4J_AQ/config/rmi.xml ORACLE_HOME/oc4j/j2ee/OC4J_AQ/config/http-web-site.xml
Point a web browser to the following URL:
https://hostname:portnumber/aqserv/servlet/AQDemoServlet
where hostname
is the server name, and portnumber
is the value discovered in the previous step. After you respond to a username/password prompt, the servlet displays:
Sample AQ Servlet AQxmlServlet is working!
Create an SSL Certificate and generate a keystore. The following files provide examples:
ORACLE_HOME/rdbms/demo/aqxmloc4j.cert ORACLE_HOME/rdbms/demo/keystore
See Also: Keytool documentation athttp://java.sun.com/j2se/1.4.2/docs/tooldocs/solaris/keytool.html |
The following tags in ORACLE_HOME
/oc4j/j2ee/OC4J_AQ/config/http-web-site.xml
indicate that the Web site is secure and keystore is used for SSL authentication:
<web-site port="443" secure="true">
....
<ssl-config
keystore="ORACLE_HOME/oc4j/j2ee/home/keystore"
keystore-password="welcome" />
</web-site>
To make the site access only HTTP requests, remove secure="true"
and <ssl-config>
from http-web-site.xml
.
Stop and restart the AQ XML servlet:
sh aqxmlctl stop sh aqxmlctl start
Internet Data Access Presentation (IDAP) uses the Content-Type of text/xml
to specify the body of the SOAP request. XML provides the presentation for IDAP request and response messages as follows:
All request and response tags are scoped in the SOAP namespace.
Oracle Streams Advanced Queuing operations are scoped in the IDAP namespace.
The sender includes namespaces in IDAP elements and attributes in the SOAP body.
The receiver processes SOAP messages that have correct namespaces and returns an invalid request error for requests with incorrect namespaces.
The SOAP namespace has the value http://schemas.xmlsoap.org/soap/envelope/
The IDAP namespace has the value http://ns.oracle.com/AQ/schemas/access
SOAP structures a message request or response as follows:
This is the root or top element in an XML tree. Its tag is SOAP:Envelope
. SOAP defines a global attribute SOAP:encodingStyle
that indicates serialization rules used instead of those described by the SOAP specification. This attribute can appear on any element and is scoped to that element and all child elements not themselves containing such an attribute. Omitting this attribute means that type specification has been followed unless overridden by a parent element.
The SOAP envelope also contains namespace declarations and additional attributes, provided they are namespace-qualified. Additional namespace-qualified subelements can follow the body.
This is the first element under the root. Its tag is SOAP:Header
. A SOAP header passes necessary information, such as the transaction identifier. The header is encoded as a child of the SOAP:Envelope
XML element. Headers are identified by the name element and are namespace-qualified. A header entry is encoded as an embedded element.
This is the Oracle Streams Advanced Queuing XML document. Its tag is SOAP:Body
, and it contains a first subelement whose name is the method name. This method request element contains elements for each input and output parameter. The element names are the parameter names. The body also contains SOAP:Fault
, indicating information about an error. The Oracle Streams Advanced Queuing XML document has the namespace http://ns.oracle.com/AQ/schemas/access
A method invocation is performed by creating the request header and body and processing the returned response header and body. The request and response headers can consist of standard transport protocol-specific and extended headers.
The POST
method within the HTTP request header performs the SOAP method invocation. The request should include the header SOAPMethodName,
whose value indicates the method to be invoked on the target. The value is of the form URI
#
method name
. For example:
SOAPMethodName: http://ns.oracle.com/AQ/schemas/access#AQXmlSend
The URI used for the interface must match the implied or specified namespace qualification of the method name element in the SOAP:Body
part of the payload. The method name must not include the "#" character.
SOAP method invocation consists of a method request and optionally a method response. The SOAP method request and method response are an HTTP request and response, respectively, whose contents are XML documents consisting of the root and mandatory body elements. These XML documents are referred to as SOAP payloads in the rest of this chapter.
A SOAP payload is defined as follows:
The SOAP root element is the top element in the XML tree.
The SOAP payload headers contain additional information that must travel with the request.
The method request is represented as an XML element with additional elements for parameters. It is the first child of the SOAP:Body
element. This request can be one of the Oracle Streams Advanced Queuing XML client requests described in the next section.
The response is the return value or an error or exception that is passed back to the client.
At the receiving site, a request can have one of the following outcomes:
The HTTP infrastructure on the receiving site is able to receive and process the request. In this case, the HTTP infrastructure passes the headers and body to the SOAP infrastructure.
The HTTP infrastructure on the receiving site cannot receive and process the request. In this case, the result is an HTTP response containing an HTTP error in the status field and no XML body.
The SOAP infrastructure on the receiving site is able to decode the input parameters, dispatch to an appropriate server indicated by the server address, and invoke an application-level function corresponding semantically to the method indicated in the method request. In this case, the result of the method request consists of a response or error.
The SOAP infrastructure on the receiving site cannot decode the input parameters, dispatch to an appropriate server indicated by the server address, and invoke an application-level function corresponding semantically to the interface or method indicated in the method request. In this case, the result of the method is an error that prevented the dispatching infrastructure on the receiving side from successful completion.
In the last two cases, additional message headers can be present in the results of the request for extensibility.
The body of a SOAP message is an IDAP message. This XML document has the namespace http://ns.oracle.com/AQ/schemas/access
. The body represents:
Server responses to client requests for enqueue, dequeue, and registration
Notifications from the server to the client
Note: Oracle Streams Advanced Queuing Internet access is supported only for 8.1or higher style queues. |
This section contains these topics:
Client send and publish requests use AQXmlSend
to enqueue to a single-consumer queue and AQXmlPublish
to enqueue to multiconsumer queues/topics
AQXmlSend
and AQXmlPublish
contain the following elements:
producer_options
This is a required element. It contains the following child elements:
destination
This element is required. It specifies the queue/topic to which messages are to be sent. It has an optional lookup_type
attribute, which determines how the destination value is interpreted. If lookup_type is DATABASE
, which is the default, then the destination is interpreted as schema.queue_name
. If lookup_type
is LDAP
, then the LDAP server is used to resolve the destination.
This element is optional. It determines when an enqueue becomes visible. The default is ON_COMMIT
, which makes the enqueue visible when the current transaction commits. If IMMEDIATE
is specified, then the effects of the enqueue are visible immediately after the request is completed. The enqueue is not part of the current transaction. The operation constitutes a transaction on its own.
transformation
This element is optional. It specifies the PL/SQL transformation to be invoked before the message is enqueued.
message_set
This is a required element and contains one or more messages. Each message consists of a message_header and a message_payload.
message_header
This element is optional. It contains the following child elements:
sender_id
If a message_header
element is included, then it must contain a sender_id
element, which specifies an application-specific identifier. The sender_id
element can contain agent_name
, address
, protocol
, and agent_alias
elements. The agent_alias
element resolves to a name, address, and protocol using LDAP.
message_id
This element is optional. It is a unique identifier of the message, supplied during dequeue.
correlation
This element is optional. It is the correlation identifier of the message.
delay
This element is optional. It specifies the duration in seconds after which a message is available for processing.
expiration
This element is optional. It specifies the duration in seconds that a message is available for dequeuing. This parameter is an offset from the delay. By default messages never expire. If a message is not dequeued before it expires, then it is moved to an exception queue in the EXPIRED
state.
priority
This element is optional. It specifies the priority of the message. The priority can be any number, including negative numbers. A smaller number indicates higher priority.
recipient_list
This element is optional. It is a list of recipients which overrides the default subscriber list. Each recipient is represented in recipient_list
by a recipient
element, which can contain agent_name
, address
, protocol
, and agent_alias
elements. The agent_alias
element resolves to a name, address, and protocol using LDAP.
message_state
This element is optional. It specifies the state of the message. It is filled in automatically during dequeue. If message_state
is 0, then the message is ready to be processed. If it is 1, then the message delay has not yet been reached. If it is 2, then the message has been processed and is retained. If it is 3, then the message has been moved to an exception queue.
exception_queue
This element is optional. It specifies the name of the queue to which the message is moved if the number of unsuccessful dequeue attempts has exceeded max_retries
or the message has expired. All messages in the exception queue are in the EXPIRED
state.
If the exception queue specified does not exist at the time of the move, then the message is moved to the default exception queue associated with the queue table, and a warning is logged in the alert log. If the default exception queue is used, then the parameter returns a NULL
value at dequeue time.
message_payload
This is a required element. It can contain different elements based on the payload type of the destination queue/topic. The different payload types are described in "IDAP Client Requests for Dequeue".
AQXmlCommit
This is an optional empty element. If it is included, then the transaction is committed at the end of the request.
Client requests for dequeue use AQXmlReceive
, which contains the following elements:
consumer_options
This is a required element. It contains the following child elements:
destination
This element is required. It specifies the queue/topic from which messages are to be received. The destination
element has an optional lookup_type
attribute, which determines how the destination value is interpreted. If lookup_type is DATABASE
, which is the default, then the destination is interpreted as schema.queue_name
. If lookup_type
is LDAP
, then the LDAP server is used to resolve the destination.
consumer_name
This element is optional. It specifies the name of the consumer. Only those messages matching the consumer name are accessed. If a queue is not set up for multiple consumers, then this field should not be specified.
wait_time
This element is optional. It specifies the number of seconds to wait if there is no message currently available which matches the search criteria.
selector
This element is optional. It specifies criteria used to select the message. It can contain child elements correlation
, message_id
, or condition
.
A dequeue condition
element is a Boolean expression using syntax similar to the WHERE
clause of a SQL query. This Boolean expression can include conditions on message properties, user object payload data properties, and PL/SQL or SQL functions. Message properties include priority
, corrid
and other columns in the queue table.
To specify dequeue conditions on a message payload, use attributes of the object type in clauses. You must prefix each attribute with tab
.user_data
as a qualifier to indicate the specific column of the queue table that stores the payload.
A dequeue condition
element cannot exceed 4000 characters.
Note: When a dequeue condition or correlation identifier is used, the order of the messages dequeued is indeterminate, and the sort order of the queue is not honored. |
This element is optional. It determines when a dequeue becomes visible. The default is ON_COMMIT
, which makes the dequeue visible when the current transaction commits. If IMMEDIATE
is specified, then the effects of the dequeue are visible immediately after the request is completed. The dequeue is not part of the current transaction. The operation constitutes a transaction on its own.
dequeue_mode
This element is optional. It specifies the locking action associated with the dequeue. The possible values are REMOVE
, BROWSE
, and LOCKED
.
REMOVE
is the default and causes the message to be read and deleted. The message can be retained in the queue table based on the retention properties. BROWSE
reads the message without acquiring any lock on it. This is equivalent to a select statement. LOCKED
reads the message and obtains a write lock on it. The lock lasts for the duration of the transaction. This is equivalent to a select for update statement.
navigation_mode
This element is optional. It specifies the position of the message that is retrieved. First, the position is determined. Second, the search criterion is applied. Finally, the message is retrieved. Possible values are FIRST_MESSAGE
, NEXT_MESSAGE
, and NEXT_TRANSACTION
.
FIRST_MESSAGE
retrieves the first message which is available and which matches the search criteria. This resets the position to the beginning of the queue. NEXT_MESSAGE
is the default and retrieves the next message which is available and which matches the search criteria. If the previous message belongs to a message group, then Oracle Streams Advanced Queuing retrieves the next available message which matches the search criteria and which belongs to the message group.NEXT_TRANSACTION
skips the remainder of the current transaction group and retrieves the first message of the next transaction group. This option can only be used if message grouping is enabled for the current queue.
transformation
This element is optional. It specifies the PL/SQL transformation to be invoked after the message is dequeued.
AQXmlCommit
This is an optional empty element. If it is included, then the transaction is committed at the end of the request.
Client requests for registration use AQXmlRegister
, which must contain a register_options
element. The register_options
element contains the following child elements:
destination
This element is required. It specifies the queue/topic on which notifications are registered. The destination
element has an optional lookup_type
attribute, which determines how the destination value is interpreted. If lookup_type is DATABASE
, which is the default, then the destination is interpreted as schema.queue_name
. If lookup_type
is LDAP
, then the LDAP server is used to resolve the destination.
consumer_name
This element is optional. It specifies the consumer name for multiconsumer queues or topics. This parameter must not be specified for single-consumer queues.
notify_url
This element is required. It specifies where notification is sent when a message is enqueued. The form can be http://
url
, mailto://
email address
or plsql://
pl/sql procedure
.
A request to commit all actions performed by the user in a session uses AQXmlCommit
. A commit request has the following format:
<?xml version="1.0"?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <AQXmlCommit xmlns="http://ns.oracle.com/AQ/schemas/access"/> </Body> </Envelope>
A request to roll back all actions performed by the user in a session uses AQXmlRollback
. Actions performed with IMMEDIATE
visibility are not rolled back. An IDAP client rollback request has the following format:
<?xml version="1.0"?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <AQXmlRollback xmlns="http://ns.oracle.com/AQ/schemas/access"/> </Body> </Envelope>
The response to an enqueue request to a single-consumer queue uses AQXmlSendResponse
. It contains the following elements:
status_response
This element contains child elements status_code
, error_code
, and error_message
. The status_code
element takes value 0
for success or -1
for failure. The error_code
element contains an Oracle error code. The error_message
element contains a description of the error.
send_result
This element contains child elements destination
and message_id
. The destination
element specifies where the message was sent. The message_id
element uniquely identifies every message sent.
The response to an enqueue request to a multiconsumer queue or topic uses AQXmlPublishResponse
. It contains the following elements:
status_response
This element contains child elements status_code
, error_code
, and error_message
. The status_code
element takes value 0
for success or -1
for failure. The error_code
element contains an Oracle error code. The error_message
element contains a description of the error.
publish_result
This element contains child elements destination
and message_id
. The destination
element specifies where the message was sent. The message_id
element uniquely identifies every message sent.
The response to a dequeue request uses AQXmlReceiveResponse
. It contains the following elements:
status_response
This element contains child elements status_code
, error_code
, and error_message
. The status_code
element takes value 0
for success or -1
for failure. The error_code
element contains an Oracle error code. The error_message
element contains a description of the error.
receive_result
This element contains child elements destination
and message_set
. The destination
element specifies where the message was sent. The message_set
element specifies the set of messages dequeued.
The response to a register request uses AQXmlRegisterResponse
. It contains the status_response
element described in "IDAP Server Response to a Dequeue Request".
The response to a commit request uses AQXmlCommitResponse. It contains the status_response
element described in "IDAP Server Response to a Dequeue Request". The response to a commit request has the following format:
<?xml version = '1.0'?> <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> <Body> <AQXmlCommitResponse xmlns="http://ns.oracle.com/AQ/schemas/access"> <status_response> <status_code>0</status_code> </status_response> </AQXmlCommitResponse> </Body> </Envelope>
The response to a rollback request uses AQXmlRollbackResponse
. It contains the status_response
element described in "IDAP Server Response to a Dequeue Request".
When an event for which a client has registered occurs, a notification is sent to the client at the URL specified in the REGISTER
request using AQXmlNotification
. It contains the following elements:
notification_options
This element has child elements destination
and consumer_name
. The destination
element specifies the destination queue/topic on which the event occurred. The consumer_name element specifies the consumer name for which the even occurred. It applies only to multiconsumer queues/topics.
message_set
This element specifies the set of message properties.
In case of an error in any of the preceding requests, a FAULT
is generated. The FAULT
element contains the following elements:
faultcode
This element specifies the error code for the fault.
faultstring
This element indicates a client error or a server error. A client error means that the request is not valid. A server error indicates that the Oracle Streams Advanced Queuing servlet has not been set up correctly.
detail
This element contains the status_response
element, which is described in "IDAP Server Response to a Dequeue Request".
Here are the steps for setting up your database for e-mail notifications:
Set the SMTP mail host by invoking DBMS_AQELM.SET_MAILHOST
as an Oracle Streams Advanced Queuing administrator.
Set the SMTP mail port by invoking DBMS_AQELM.SET_MAILPORT
as an Oracle Streams Advanced Queuing administrator. If not explicit, set defaults to 25.
Set the SendFrom address by invoking DBMS_AQELM.SET_SENDFROM
.
After setup, you can register for e-mail notifications using the Oracle Call Interface (OCI) or PL/SQL API.
application programming interface
The calling conventions by which an application program accesses operating system and other services.
approximate CSCN
An approximate system change number value, based on the current SCN of the database when a transaction that has enqueued messages into a commit-time queue is committed.
asynchronous
A process in a multitasking system is asynchronous if its execution can proceed independently in the background. Other processes can be started before the asynchronous process has finished. The opposite of synchronous.
BFILE
An external binary file that exists outside the database tablespaces residing in the operating system.
binary large object
A large object datatype whose content consists of binary data. This data is considered raw, because its structure is not recognized by the database.
broadcast
A publish/subscribe mode in which the message producer does not know the identity of any message consumer. This mode is similar to a radio or television station.
buffered queue
Buffered queues support queuing of messages with buffered attributes (buffered messages) and materialize them in memory. If the memory devoted to a buffered message is required for a newer message, or if a buffered message has exceeded a stipulated duration in memory, then that buffered message is swapped to the underlying queue table. The memory for buffered messages comes from a separate pool called the streams pool. Buffered messages cannot be recovered if the database is bounced. Messages that have no buffered attributes set are queued as persistent messages in the underlying persistent queue.
character large object
The large object datatype whose value is composed of character data corresponding to the database character set. A character large object can be indexed and searched by the Oracle Text search engine.
ConnectionFactory
A ConnectionFactory encapsulates a set of connection configuration parameters that has been defined by an administrator. A client uses it to create a connection with a Java Message Service provider.
data manipulation language
Data manipulation language (DML) statements manipulate database data. For example, querying, inserting, updating, and deleting rows of a table are all DML operations; locking a table or view and examining the execution plan of an SQL statement are also DML operations.
Database Configuration Assistant
An Oracle Database tool for creating and deleting databases and for managing database templates.
exception queue
Messages are transferred to an exception queue if they cannot be retrieved and processed for some reason.
index-organized table
Unlike an ordinary table whose data is stored as an unordered collection, data for an index-organized table is stored in a B-tree index structure sorted on a primary key. Besides storing the primary key column values of an index-organized table row, each index entry in the B-tree stores the nonkey column values as well.
Internet Data Access Presentation
The Simple Object Access Protocol (SOAP) specification for Oracle Streams Advanced Queuing operations. IDAP defines the XML message structure for the body of the SOAP request. An IDAP-structured message is transmitted over the Internet using HTTP(S).
Inter-process Communication
Exchange of data between one process and another, either within the same computer or over a network. It implies a protocol that guarantees a response to a request.
Java Database Connectivity
An industry-standard Java interface for connecting to a relational database from a Java program, defined by Sun Microsystems.
Java Message Service
A messaging standard defined by Sun Microsystems, Oracle, IBM, and other vendors. JMS is a set of interfaces and associated semantics that define how a JMS client accesses the facilities of an enterprise messaging product.
Java Naming and Directory Interface
A programming interface from Sun for connecting Java programs to naming and directory services.
Java Virtual Machine
The Java interpreter that converts the compiled Java bytecode into the machine language of the platform and runs it. JVMs can run on a client, in a browser, in a middle tier, on an intranet, on an application server such as Oracle Application Server 10g, or in a database server such as Oracle Database 10g.
JDBC driver
The vendor-specific layer of Java Database Connectivity that provides access to a particular database. Oracle Database provides three JDBC drivers--Thin, OCI, and KPRB.
JMS connection
An active connection of a client to its JMS provider, typically an open TCP/IP socket (or a set of open sockets) between a client and a provider's service daemon.
JMS message
JMS messages consist of a header, one or more optional properties, and a message payload.
JMS topic
Equivalent to a multiconsumer queue in the other Oracle Streams Advanced Queuing interfaces.
Lightweight Directory Access Protocol
A standard, extensible directory access protocol. It is a common language that LDAP clients and servers use to communicate. The framework of design conventions supporting industry-standard directory products, such as the Oracle Internet Directory.
local consumer
A local consumer dequeues the message from the same queue into which the producer enqueued the message.
logical change record
An object with a specific format that describes a database change, captured from the redo log by a capture process or user application. Capture processes enqueue messages containing logical change records (LCRs) only into ANYDATA
queues. For improved performance, these LCRs are always stored in a buffered queue.
message
The smallest unit of information inserted into and retrieved from a queue. A message consists of control information (metadata) and payload (data).
multicast
A publish/subscribe mode in which the message producer knows the identity of each consumer. This mode is also known as point-to-multipoint.
national character large object
The large object datatype whose value is composed of character data corresponding to the database national character set.
nonpersistent
Nonpersistent queues store messages in memory. They are generally used to provide an asynchronous mechanism to send notifications to all users that are currently connected. Nonpersistent queues are deprecated in Oracle Streams Advanced Queuing 10g Release 2 (10.2). Oracle recommends that you use buffered messaging instead.
object type
An object type encapsulates a data structure along with the functions and procedures needed to manipulate the data. When you define an object type using the CREATE TYPE
statement, you create an abstract template that corresponds to a real-world object.
Online Transaction Processing
Online transaction processing systems are optimized for fast and reliable transaction handling. Compared to data warehouse systems, most OLTP interactions involve a relatively small number of rows, but a larger group of tables.
Oracle Call Interface
An application programming interface that enables data and schema manipulation in Oracle Database.
Oracle Java Message Service
Oracle Java Message Service (OJMS) provides a Java API for Oracle Streams Advanced Queuing based on the Java Message Service (JMS) standard. OJMS supports the standard JMS interfaces and has extensions to support the Oracle Streams Advanced Queuing administrative operations and other Oracle Streams Advanced Queuing features that are not a part of the standard.
Oracle Objects for OLE
A custom control (OCX or ActiveX) combined with an object linking and embedding (OLE) in-process server that lets you plug native Oracle Database functionality into your Windows applications.
publish/subscribe
A type of messaging in which a producer enqueues a message to one or more multiconsumer queues, and then the message is dequeued by several subscribers. The published message can have a wide dissemination mode called broadcast or a more narrowly aimed mode called multicast.
QMNC
Queue monitor coordinator. It dynamically spawns slaves qXXX depending on the system load. The slaves do various background tasks.
queue table
A database table where queues are stored. Each queue table contains a default exception queue.
recipient
An agent authorized by the enqueuer or queue administrator to retrieve messages. The enqueuer can explicitly specify the consumers who can retrieve the message as recipients of the message. A queue administrator can specify a default list of recipients who can retrieve messages from a queue. A recipient specified in the default list is known as a subscriber. If a message is enqueued without specifying the recipients, then the message is sent to all the subscribers. Specific messages in a queue can be directed toward specific recipients, who may or may not be subscribers to the queue, thereby overriding the subscriber list.
If only the name of the recipient is specified, then the recipient must dequeue the message from the queue in which the message was enqueued. If the name and an address of the recipient are specified with a protocol value of 0, then the address should be the name of another queue in the same database or another installation of Oracle Database. If the recipient's name is NULL
, then the message is propagated to the specified queue in the address and can be dequeued by any subscriber of the queue specified in the address. If the protocol field is nonzero, then the name and address are not interpreted by the system, and the message can be dequeued by a special consumer.
remote consumer
A remote consumer dequeues from a queue that is different from the queue where the message was enqueued.
rules
Boolean expressions that define subscriber interest in subscribing to messages. The expressions use syntax similar to the WHERE
clause of a SQL query and can include conditions on: message properties (currently priority and correlation identifier), user data properties (object payloads only), and functions. If a rule associated with a subscriber evaluates to TRUE
for a message, then the message is sent to that subscriber even if the message does not have a specified recipient.
rules engine
Oracle Database software that evaluates rules. Rules are database objects that enable a client to perform an action when an event occurs and a condition is satisfied. Rules are similar to conditions in WHERE clauses of SQL queries. Both user-created applications and Oracle Database features, such as Oracle Streams Advanced Queuing, can be clients of the rules engine.
schema
A collection of database objects, including logical structures such as tables, views, sequences, stored procedures, synonyms, indexes, clusters, and database links. A schema has the name of the user who controls it.
servlet
A Java program that runs as part of a network service and responds to requests from clients. It is typically an HTTP server.
Simple Object Access Protocol
A minimal set of conventions for invoking code using XML over HTTP defined by World Wide Web Consortium.
System Global Area
A group of shared memory structures that contain data and control information for one Oracle Database instance. The SGA and Oracle Database processes constitute an Oracle Database instance. Oracle Database automatically allocates memory for an SGA whenever you start an instance and the operating system reclaims the memory when you shut down the instance. Each instance has one and only one SGA.
synchronous
Two or more processes are synchronous if they depend upon the occurrences of specific events such as common timing signals. The opposite of asynchronous.
transformation
A mapping from one Oracle data type to another, represented by a SQL function that takes the source data type as input and returns an object of the target data type. A transformation can be specified during enqueue, to transform the message to the correct type before inserting it into the queue. It can be specified during dequeue to receive the message in the wanted format. If specified with a remote consumer, then the message is transformed before propagating it to the destination queue.
VARRAY
An ordered set of data elements. All elements of a given array are of the same datatype. Each element has an index, which is a number corresponding to the element's position in the array. The number of elements in an array is the size of the array. Oracle Database allows arrays to be of variable size.
wildcard
A special character or character sequence which matches any character in a string comparison.
This guide describes features of application development and integration using Oracle Streams Advanced Queuing (AQ). This information applies to versions of the Oracle Database server that run on all platforms, unless otherwise specified.
This Preface contains these topics:
This guide is intended for programmers who develop applications that use Oracle Streams Advanced Queuing.
To use this document, you need knowledge of an application development language and object-relational database management concepts.
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc
.
Access to Oracle Support
Oracle customers have access to electronic support through My Oracle Support. For information, visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info
or visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=trs
if you are hearing impaired.
For more information, see these Oracle resources:
Many of the examples in this book use the sample schemas, which are installed by default when you select the Basic Installation option with an Oracle Database installation. Refer to Oracle Database Sample Schemas for information on how these schemas were created and how you can use them yourself.
The following text conventions are used in this document:
Convention | Meaning |
---|---|
boldface | Boldface type indicates graphical user interface elements associated with an action, or terms defined in text or the glossary. |
italic | Italic type indicates book titles, emphasis, or placeholder variables for which you supply particular values. |
monospace | Monospace type indicates commands within a paragraph, URLs, code in examples, text that appears on the screen, or text that you enter. |