Oracle8i Application Developer's Guide - Advanced Queuing Release 8.1.5 A68005-01 |
|
This chapter introduces and details the Java Application Programmer's Interface for Advanced Queuing under the following headings:
The Java AQ API supports both the administrative and operational features of Oracle AQ. In developing Java programs for messaging applications, you will use JDBC to open a connection to the database and then the Java AQ API for message queuing. This means that you will no longer be required to use the PL/SQL interfaces.
The following sections describe the common interfaces and classes based on the current PL/SQL interfaces. The common interfaces are prefixed with "AQ". These interfaces will have different implementations in Oracle8i and Oracle Lite. In this document we describe the common interfaces and their corresponding Oracle8i implementations, which are in turn prefixed with "AQOracle".
The java AQ classes are located in $ORACLE_HOME
/rdbms
/jlib
/aqapi
.jar
. These classes can be used with any Oracle8i JDBC driver. If your application uses the OCI8 or thin JDBC driver, you must include $ORACLE_HOME
/rdbms
/jlib
/aqapi
.jar
in the CLASSPATH
. If the application is using the KPRB driver and accessing the java AQ API from java stored procedures, you must first load the aqapi
.jar
file into the database using the "loadjava" utility.
Chapter 8, "Oracle Advanced Queuing by Example" contains the following examples:
Set up for the test_aqjava
class is described in "Setup for AQ Examples".
The way to create a multi-consumer queue is described in the "AQSession".
The various implementations of the Java AQ API are managed via an AQDriverManager
. Both OLite and Oracle8i will have an AQDriver
which is registered with the AQDriverManager
. The driver manager is used to create an AQSession
which can be used to perform messaging tasks.
When the AQDriverManager
.createAQSession
() method is invoked, it calls the appropriate AQDriver
(amongst the registered drivers) depending on the parameter passed to the createAQSession
() call.
The Oracle8i AQDriver
expects a valid JDBC connection to be passed in as a parameter to create an AQSession. Users must have the execute privilege on the DBMS_AQIN
package in order to use the AQ Java interfaces. Users can also acquire these rights through the AQ_USER_ROLE
or the AQ_ADMINSTRATOR_ROLE
.Users will also need the appropriate system and queue privileges for 8.1 style queue tables.
This method returns the list of drivers registered with the driver manager. It returns a Vector of strings containing the names of the registered drivers.
public static java.util.Vector getDrivers()
This method creates an AQSession.
public static AQSession getAQSession (java.lang.Object conn) throws AQException
Parameter | Meaning |
---|---|
|
if the user is using the |
Currently Java AQ objects are not thread safe. Therefore, methods on AQSession
, AQQueueTable
, AQQueue
and other AQ objects should not be called concurrently from different threads. You can pass these objects between threads, but the program must ensure that the methods on these AQ objects are not invoked concurrently.
We recommend that multithreaded programs create a different AQSession
in each thread (using the same or a different JDBC connection) and get new queue table and queue handles using the getQueueTable
and getQueue
methods in AQSession
.
This method is used by various implementations of the AQ driver to register themselves with the driver manager (this method is not directly called by client programs)
public static void registerDriver(AQDriver aq_driver)
Connection db_conn; /* JDBC connection */ AQSession aq_sess; /* AQSession */ /* JDBC setup and connection creation: */ class.forName("oracle.jdbc.driver.OracleDriver"); db_conn = DriverManager.getConnection ( "jdbc:oracle:oci8:@", "aquser", "aquser"); db_conn.setAutoCommit(false); /* Load the Oracle8i AQ driver: */ class.forName("oracle.AQ.AQOracleDriver"); /* Create an AQ Session: */ aq_sess = AQDriverManager.createAQSession(db_conn);
In general use only the interfaces and classes that are common to both implementations (as described in the first two tables). This will ensure that your applications are portable between Oracle 8i and Olite AQ implementations.
The AQOracle classes should not be used unless there is a method in these classes that is not available in the common interfaces.
Note that since the AQQueue
interface extends AQQueueAdmin
, all queue administrative and operation functionality is available via AQQueue
.
This method creates a new queue table in a particular user's schema according to the properties specified in the AQQueueTableProperty
object passed in.
public AQQueueTable createQueueTable(java.lang.String owner, java.lang.String name, AQQueueTableProperty property) throws AQException
Parameter | Meaning |
---|---|
|
schema (user) in which to create the queue table |
|
name of the queue table |
|
queue table properties |
AQQueueTable
object
This method is used to get a handle to an existing queue table.
public AQQueueTable getQueueTable(java.lang.String owner, java.lang.String name)
Parameter | Meaning |
---|---|
|
schema (user) in which the queue table resides |
|
name of the queue table |
AQQueueTable
object
This method creates a queue in a queue_table with the specified queue properties. It uses the same schema name that was used to create the queue table.
public AQQueue createQueue(AQQueueTable q_table, java.lang.String q_name, AQQueueProperty q_property) throws AQException
Parameter | Meaning |
---|---|
|
queue table in which to create queue |
|
name of the queue to be created |
|
queue properties |
AQQueue
object
This method can be used to get a handle to an existing queue.
public AQQueue getQueue(java.lang.String owner, java.lang.String name)
Parameter | Meaning |
---|---|
|
schema (user) in which the queue table resides |
|
name of the queue |
AQQueue
object
Currently the java AQ API supports only queues with raw payloads. If you try to access queue tables that contain queues with object payloads you will get an AQException
with the message "payload type not supported."
Here an 'aqjava' user is setup as follows:
CONNECT sys/change_on_install AS sysdba DROP USER aqjava CASCADE; GRANT CONNECT, RESOURCE, AQ_ADMINISTRATOR_ROLE TO aqjava IDENTIFIED BY aqjava; GRANT EXECUTE ON SYS.DBMS_AQADM TO aqjava; GRANT EXECUTE ON SYS.DBMS_AQ TO aqjava; CONNECT aqjava/aqjava
Next we set up the main class from which we will call subsequent examples and handle exceptions.
import java.sql.*; import oracle.AQ.*; public class test_aqjava { public static void main(String args[]) { AQSession aq_sess = null; try { aq_sess = createSession(args); /* now run the test: */ runTest(aq_sess); } catch (Exception ex) { System.out.println("Exception-1: " + ex); ex.printStackTrace(); } } }
Next, an AQ Session is created for the 'aqjava' user as shown in the AQDriverManager section above: public static AQSession createSession(String args[]) { Connection db_conn; AQSession aq_sess = null; try { Class.forName("oracle.jdbc.driver.OracleDriver"); /* your actual hostname, port number, and SID will vary from what follows. Here we use 'dlsun736,' '5521,' and 'test,' respectively: */ db_conn = DriverManager.getConnection( "jdbc:oracle:thin:@dlsun736:5521:test", "aqjava", "aqjava"); System.out.println("JDBC Connection opened "); db_conn.setAutoCommit(false); /* Load the Oracle8i AQ driver: */ Class.forName("oracle.AQ.AQOracleDriver"); /* Create an AQ Session: */ aq_sess = AQDriverManager.createAQSession(db_conn); System.out.println("Successfully created AQSession "); } catch (Exception ex) { System.out.println("Exception: " + ex); ex.printStackTrace(); } return aq_sess; }
Now, with the ' runTest' class, called from the above main class, we will create a queue table and queue for the 'aqjava' user.
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTableProperty qtable_prop; AQQueueProperty queue_prop; AQQueueTable q_table; AQQueue queue; /* Create a AQQueueTableProperty object (payload type - RAW): */ qtable_prop = new AQQueueTableProperty("RAW"); /* Create a queue table called aq_table1 in aqjava schema: */ q_table = aq_sess.createQueueTable ("aqjava", "aq_table1", qtable_prop); System.out.println("Successfully created aq_table1 in aqjava schema"); /* Create a new AQQueueProperty object: */ queue_prop = new AQQueueProperty(); /* Create a queue called aq_queue1 in aq_table1: */ queue = aq_sess.createQueue (q_table, "aq_queue1", queue_prop); System.out.println("Successfully created aq_queue1 in aq_table1"); }
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTable q_table; AQQueue queue; /* Get a handle to queue table - aq_table1 in aqjava schema: */ q_table = aq_sess.getQueueTable ("aqjava", "aq_table1"); System.out.println("Successful getQueueTable"); /* Get a handle to a queue - aq_queue1 in aqjava schema: */ queue = aq_sess.getQueue ("aqjava", "aq_queue1"); System.out.println("Successful getQueue"); }
This class contains some constants used in the java AQ API .
VISIBILITY_IMMEDIATE public static final int VISIBILITY_IMMEDIATE VISIBILITY_ONCOMMIT public static final int VISIBILITY_ONCOMMIT
RAW_TYPE_PAYLOAD public static final int RAW_TYPE_PAYLOAD
This object specifies the producer or a consumer of a message.
There are two implementations of the constructor, each of which allocates a new AQAgent
with the specified parameters.
public AQAgent(java.lang.String name, java.lang.String address, double protocol) public AQAgent(java.lang.String name, java.lang.String address)
Parameter | Meaning |
---|---|
|
agent name |
|
agent address |
|
agent protocol (required only in the first constructor); default is 0 |
This method gets the agent name.
public java.lang.String getName() throws AQException
This method sets the agent name.
public void setName(java.lang.String name) throws AQException
Parameter | Meaning |
---|---|
|
Agent name |
This method gets the agent address.
public java.lang.String getAddress() throws AQException
This method sets the agent address.
public void setAddress(java.lang.String address) throws AQException
Parameter | Meaning |
---|---|
|
queue at a specific destination |
This method gets the agent protocol.
public int getProtocol() throws AQException
This method sets the agent protocol.
public void setProtocol(int protocol) throws AQException
Parameter | Meaning |
---|---|
|
Agent protocol |
This class represents queue table properties.
public static final int NONE public static final int TRANSACTIONAL
This method creates an AQQueueTableProperty
object with default property values and the specified payload type.
public AQQueueTableProperty(java.lang.String p_type)
Parameter | Meaning |
---|---|
|
payload type: this is " |
This method returns "RAW
" for raw payloads or the object type for object payloads.
public java.lang.String getPayloadType() throws AQException
This method is used to set the payload type.
public void setPayloadType(java.lang.String p_type) throws AQException
Parameter | Meaning |
---|---|
|
payload type: this is "RAW" for queue tables that will contain raw payloads or the object type for queue tables that will contain structured payloads |
This method is used to set the storage clause to be used to create the queue table.
public void setStorageClause(java.lang.String s_clause) throws AQException
Parameter | Meaning |
---|---|
|
storage parameter: this clause is used in the ` |
This method gets the sort order that is used.
public java.lang.String getSortOrder() throws AQException
The sort order used
This method sets the sort order to be used.
public void setSortOrder(java.lang.String s_order) throws AQException
This method queries whether the queues created in the table can have multiple consumers per message or not.
public boolean isMulticonsumerEnabled() throws AQException
TRUE
if the queues created in the table can have multiple consumers per message.
FALSE
if the queues created in the table can have only one consumer per message.
This method determines whether the queues created in the table can have multiple consumers per message or not.
public void setMultiConsumer(boolean enable) throws AQException
Parameter | Meaning |
---|---|
|
|
This method is used to get the message grouping behavior for the queues in this queue table.
public int getMessageGrouping() throws AQException
NONE
: each message is treated individually
TRANSACTIONAL
: all messages enqueued as part of one transaction are considered part of the same group and can be dequeued as a group of related messages.
This method is used to set the message grouping behavior for queues created in this queue table.
public void setMessageGrouping(int m_grouping) throws AQException
Parameter | Meaning |
---|---|
|
|
This method gets the queue table comment.
public java.lang.String getComment() throws AQException
This method sets a comment.
public void setComment(java.lang.String qt_comment) throws AQException
Parameter | Meaning |
---|---|
|
comment |
This method gets the compatible property.
public java.lang.String getCompatible() throws AQException
This method sets the compatible property.
public void setCompatible(java.lang.String qt_compatible) throws AQException
Parameter | Meaning |
---|---|
|
compatible property |
This method gets the primary instance.
public int getPrimaryInstance() throws AQException
This method sets the primary instance.
public void setPrimaryInstance(int inst) throws AQException
Parameter | Meaning |
---|---|
|
primary instance |
This method gets the secondary instance.
public int getSecondaryInstance() throws AQException
This method sets the secondary instance.
public void setSecondaryInstance(int inst) throws AQException
Parameter | Meaning |
---|---|
|
secondary instance |
Set up the test_aqjava class as described in "Setup for AQ Examples".
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTableProperty qtable_prop; /* Create AQQueueTable Property object: */ qtable_prop = new AQQueueTableProperty("RAW"); qtable_prop.setSortOrder("PRIORITY"); }
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTableProperty qtable_prop; /* Create AQQueueTable Property object: */ qtable_prop = new AQQueueTableProperty("RAW"); qtable_prop.setComment("Qtable with raw payload"); qtable_prop.setCompatible("8.1"); }
This class represents queue properties.
public static final int NORMAL_QUEUE public static final int EXCEPTION_QUEUE public static final int INFINITE /* infinite retention */
This method creates a new AQQueueProperty
object with default property values.
public AQQueueProperty()
This method gets the queue type .
public int getQueueType() throws AQException
NORMAL_QUEUE
or EXCEPTION_QUEUE
This method is used to set the queue type.
public void setQueueType(int q_type) throws AQException
Parameter | Meaning |
---|---|
|
|
This method gets the maximum retries for dequeue with REMOVE
mode.
public int getMaxRetries() throws AQException
This method sets the maximum retries for dequeue with REMOVE
mode.
public void setMaxRetries(int retries) throws AQException public void setMaxRetries(Integer retries) throws AQException
This method sets the retry interval, that is the time before this message is scheduled for processing after an application rollback. Default is 0.
public void setRetryInterval(double interval) throws AQException public void setRetryInterval(Double interval) throws AQException
Parameter | Meaning |
---|---|
|
retry interval; specifying |
This method gets the retry interval.
public double getRetryInterval() throws AQException
This method gets the retention time.
public double getRetentionTime() throws AQException
This method gets the retention time.
public void setRetentionTime(double r_time) throws AQException public void setRetentionTime(Double r_time) throws AQException
Parameter | Meaning |
---|---|
|
retention time; specifying |
This method gets the queue comment.
public java.lang.String getComment() throws AQException
This method sets the queue comment.
public void setComment(java.lang.String qt_comment) throws AQException
Parameter | Meaning |
---|---|
qt_comment |
queue comment |
Set up the test_aqjava class as described in Setup for AQ Examples.
{ AQQueueProperty q_prop; q_prop = new AQQueueProperty(); q_prop.setRetentionTime(15); /* set retention time */ q_prop.setRetryInterval(30); /* set retry interval */ }
The AQQueueTable interface contains methods for queue table administration.
This method gets the queue table owner.
public java.lang.String getOwner() throws AQException
This method gets the queue table name.
public java.lang.String getName() throws AQException
This method gets the queue table properties.
public AQQueueTableProperty getProperty() throws AQException
AQQueueTableProperty
object
This method drops the current queue table.
public void drop(boolean force) throws AQException
Parameter | Meaning |
---|---|
force |
|
This method is used to alter queue table properties.
public void alter(java.lang.String comment, int primary_instance, int secondary_instance) throws AQException public void alter(java.lang.String comment) throws AQException
Parameter | Meaning |
---|---|
|
new comment |
|
new value for primary instance |
|
new value for secondary instance |
This method is used to create a queue in this queue table.
public AQQueue createQueue(java.lang.String queue_name, AQQueueProperty q_property) throws AQException
Parameter | Meaning |
---|---|
|
name of the queue to be created |
|
queue properties |
AQQueue
object
This method is used to drop a queue in this queue table.
public void dropQueue(java.lang.String queue_name) throws AQException
Parameter | Meaning |
---|---|
queue_name |
name of the queue to be dropped |
Set up the test_aqjava class as described in Setup for AQ Examples.
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTableProperty qtable_prop; AQQueueProperty queue_prop; AQQueueTable q_table; AQQueue queue; /* Create a AQQueueTable property object (payload type - RAW): */ qtable_prop = new AQQueueTableProperty("RAW"); /* Create a queue table called aq_table2 in aquser schema: */ qtable = aq_sess.createQueueTable ("aquser", "aq_table2", qtable_prop); System.out.println("Successfully createQueueTable"); /* Create a new AQQueueProperty object: */ queue_prop = new AQQueueProperty(); /* Create a queue called aq_queue2 in aq_table2: */ queue = qtable.createQueue ("aq_queue2", queue_prop); System.out.println("Successful createQueue"); }
{ AQQueueTableProperty qtable_prop; AQQueueTable q_table; /* Get a handle to the queue table called aq_table2 in aquser schema: */ q_table = aq_sess.getQueueTable ("aqjava", "aq_table2"); System.out.println("Successful getQueueTable"); /* Get queue table properties: */ qtable_prop = q_table.getProperty(); /* Alter the queue table: */ q_table.alter("altered queue table"); /* Drop the queue table (and automatically drop queues inside it): */ q_table.drop(true); System.out.println("Successful drop"); }
This method is used to enable enqueue and dequeue on this queue.
public void start(boolean enqueue, boolean dequeue) throws AQException
Parameter | Meaning |
---|---|
|
|
|
|
This method is used to enable enqueue on this queue . This is equivalent to start(TRUE,
FALSE)
public void startEnqueue() throws AQException
This method is used to enable dequeue on this queue. This is equivalent to start(FALSE,
TRUE
).
public void startDequeue() throws AQException
This method is used to disable enqueue/dequeue on this queue.
public void stop(boolean enqueue, boolean dequeue, boolean wait) throws AQException
This method is used to disable enqueue on a queue. This is equivalent to stop(TRUE,
FALSE,
wait)
.
public void stopEnqueue(boolean wait) throws AQException
Parameter | Meaning |
---|---|
|
|
This method is used to disable dequeue on a queue. This is equivalent to stop(FALSE,
TRUE,
wait)
.
public void stopDequeue(boolean wait) throws AQException
Parameter | Meaning |
---|---|
|
|
This method is used to drop a queue
public void drop() throws AQException
This method is used to alter queue properties
public void alterQueue(AQQueueProperty property) throws AQException
Parameter | Meaning |
---|---|
|
|
This method is used to add a subscriber for this queue.
public void addSubscriber(AQAgent subscriber, java.lang.String rule) throws AQException
Parameter | Meaning |
---|---|
|
the |
|
a conditional expression based on message properties, and the message data properties |
This method removes a subscriber from a queue.
public void removeSubscriber(AQAgent subscriber) throws AQException
Parameter | Meaning |
---|---|
|
the |
This method alters properties for a subscriber to a queue.
public void alterSubscriber(AQAgent subscriber, java.lang.String rule) throws AQException
Parameter | Meaning |
---|---|
|
the |
|
a conditional expression based on message properties, the message data properties |
This method is used to grant queue privileges to users and roles. The method has been overloaded. The second implementation is equivalent to to calling the first imeplementation with grant_option
=
FALSE
.
public void grantQueuePrivilege(java.lang.String privilege, java.lang.String grantee, boolean grant_option) throws AQException public void grantQueuePrivilege(java.lang.String privilege, java.lang.String grantee) throws AQException
This method is used to revoke a queue privilege.
public void revokeQueuePrivilege(java.lang.String privilege, java.lang.String grantee) throws AQException
Parameter | Meaning |
---|---|
|
specifies the privilege to be revoked |
|
specifies the grantee(s); the grantee(s) can be a user, a role or the |
This method is used to schedule propagation from a queue to a destination identified by a database link.
public void schedulePropagation(java.lang.String destination, java.util.Date start_time, java.lang.Double duration, java.lang.String next_time, java.lang.Double latency) throws AQException
This method is used to unschedule a previously scheduled propagation of messages from the current queue to a destination identfied by a specific database link..
public void unschedulePropagation(java.lang.String destination) throws AQException
Parameter | Meaning |
---|---|
destination |
specifies the destination database link. |
This method is used to alter a propagation schedule.
public void alterPropagationSchedule(java.lang.String destination, java.lang.Double duration, java.lang.String next_time, java.lang.Double latency)throws AQException
This method is used to enable a propagation schedule.
public void enablePropagationSchedule(java.lang.String destination) throws AQException
Parameter | Meaning |
---|---|
destination |
specifies the destination database link. |
This method is used to disable a propagation schedule.
public void disablePropagationSchedule(java.lang.String destination) throws AQException
Parameter | Meaning |
---|---|
destination |
specifies the destination database link. |
Set up the test_aqjava class. For more information, see "Setup for AQ Examples"
{ AQQueueTableProperty qtable_prop; AQQueueProperty queue_prop; AQQueueTable q_table; AQQueue queue; /* Create a AQQueueTable property object (payload type - RAW): */ qtable_prop = new AQQueueTableProperty("RAW"); qtable_prop.setCompatible("8.1"); /* Create a queue table called aq_table3 in aqjava schema: */ q_table = aq_sess.createQueueTable ("aqjava", "aq_table3", qtable_prop); System.out.println("Successful createQueueTable"); /* Create a new AQQueueProperty object: */ queue_prop = new AQQueueProperty(); /* Create a queue called aq_queue3 in aq_table3: */ queue = aq_sess.createQueue (q_table, "aq_queue3", queue_prop); System.out.println("Successful createQueue"); /* Enable enqueue/dequeue on this queue: */ queue.start(); System.out.println("Successful start queue"); /* Grant enqueue_any privilege on this queue to user scott: */ queue.grantQueuePrivilege("ENQUEUE", "scott"); System.out.println("Successful grantQueuePrivilege"); }
public static void runTest(AQSession aq_sess) throws AQException { AQQueueTableProperty qtable_prop; AQQueueProperty queue_prop; AQQueueTable q_table; AQQueue queue; AQAgent subs1, subs2; /* Create a AQQueueTable property object (payload type - RAW): */ qtable_prop = new AQQueueTableProperty("RAW"); System.out.println("Successful setCompatible"); /* Set multiconsumer flag to true: */ qtable_prop.setMultiConsumer(true); /* Create a queue table called aq_table4 in aqjava schema: */ q_table = aq_sess.createQueueTable ("aqjava", "aq_table4", qtable_prop); System.out.println("Successful createQueueTable"); /* Create a new AQQueueProperty object: */ queue_prop = new AQQueueProperty(); /* Create a queue called aq_queue4 in aq_table4 */ queue = aq_sess.createQueue (q_table, "aq_queue4", queue_prop); System.out.println("Successful createQueue"); /* Enable enqueue/dequeue on this queue: */ queue.start(); System.out.println("Successful start queue"); /* Add subscribers to this queue: */ subs1 = new AQAgent("GREEN", null, 0); subs2 = new AQAgent("BLUE", null, 0); queue.addSubscriber(subs1, null); /* no rule */ System.out.println("Successful addSubscriber 1"); queue.addSubscriber(subs2, "priority < 2"); /* with rule */ System.out.println("Successful addSubscriber 2"); }
This interface supports the operational interfaces of queues. AQQueue
extends AQQueueAdmin
. Hence, you can also use adminstrative functions through this interface.
This method gets the queue owner.
public java.lang.String getOwner() throws AQException
This method gets the queue name.
public java.lang.String getName() throws AQException
This method gets the name of the queue table in which the queue resides.
public java.lang.String getQueueTableName() throws AQException
This method is used to get the queue properties.
public AQQueueProperty getProperty() throws AQException
AQQueueProperty
object
This method is used to create a new AQMessage
object that can be populated with data to be enqueued.
public AQMessage createMessage() throws AQException
AQMessage
object
This method is used to enqueue a message in a queue.
public byte[] enqueue(AQEnqueueOption enq_option, AQMessage message) throws AQException
Parameter | Meaning |
---|---|
|
|
|
|
Message id of the the enqueued message. The AQMessage object's messageId field is also populated after the completion of this call.
This method is used to dequeue a message from a queue.
public AQMessage dequeue(AQDequeueOption deq_option) throws AQException
Parameter | Meaning |
---|---|
deq_option |
|
AQMessage
,the dequeued message
This method is used to get a subscriber list for the queue.
public AQAgent[] getSubscribers() throws AQException
An array of AQAgents
This class is used to specify options available for the enqueue operation.
public static final int DEVIATION_NONE public static final int DEVIATION_BEFORE public static final int DEVIATION_TOP public static final int VISIBILITY_ONCOMMIT public static final int VISIBILITY_IMMEDIATE
There are two constructors available. The first creates an object with the specified options, the second creates an object with the default options.
public AQEnqueueOption(int visibility, byte[] relative_msgid, int sequence_deviation) public AQEnqueueOption()
This method gets the visibility.
public int getVisibility() throws AQException
VISIBILITY_IMMEDIATE
or VISIBILITY_ONCOMMIT
This method sets the visibility.
public void setVisibility(int visibility) throws AQException
Parameter | Meaning |
---|---|
|
|
This method gets the relative message id.
public byte[] getRelMessageId() throws AQException
This method gets the sequence deviation.
public int getSequenceDeviation() throws AQException
This method specfies whether the message being enqueued should be dequeued before other message(s) already in the queue
public void setSequenceDeviation(int sequence_deviation, byte[] relative_msgid) throws AQException
This class is used to specify the options available for the dequeue option.
public static final int NAVIGATION_FIRST_MESSAGE public static final int NAVIGATION_NEXT_TRANSACTION public static final int NAVIGATION_NEXT_MESSAGE public static final int DEQUEUE_BROWSE public static final int DEQUEUE_LOCKED public static final int DEQUEUE_REMOVE public static final int DEQUEUE_REMOVE_NODATA public static final int WAIT_FOREVER public static final int WAIT_NONE public static final int VISIBILITY_ONCOMMIT public static final int VISIBILITY_IMMEDIATE
This method creates an object with the default options.
public AQDequeueOption()
This method gets consumer name.
public java.lang.String getConsumerName() throws AQException
This method sets consumer name
public void setConsumerName(java.lang.String consumer_name) throws AQException
Parameter | Meaning |
---|---|
consumer_name |
Agent name |
This method gets dequeue mode
public int getDequeueMode() throws AQException
DEQUEUE_BROWSE
, DEQUEUE_LOCKED
, DEQUEUE_REMOVE
or DEQUEUE_REMOVE_NODATA
This method sets the dequeue mode.
public void setDequeueMode(int dequeue_mode) throws AQException
Parameter | Meaning |
---|---|
dequeue_mode |
|
This method gets the navigation mode.
public int getNavigationMode() throws AQException
NAVIGATION_FIRST_MESSAGE
or NAVIGATION_NEXT_MESSAGE
or NAVIGATION_NEXT_TRANSACTION
This method sets the navigation mode.
public void setNavigationMode(int navigation) throws AQException
Parameter | Meaning |
---|---|
navigation |
|
This method gets the visibility.
public int getVisibility() throws AQException
VISIBILITY_IMMEDIATE
or VISIBILITY_ONCOMMIT
This method sets the visibility.
public void setVisibility(int visibility) throws AQException
Parameter | Meaning |
---|---|
|
|
This method gets the wait time.
public int getWaitTime() throws AQException
WAIT_FOREVER
or WAIT_NONE
or the actual time in seconds
This method sets the wait time.
public void setWaitTime(int wait_time) throws AQException
Parameter | Meaning |
---|---|
|
|
This method gets the message id.
public byte[] getMessageId() throws AQException
This method sets the message id.
public void setMessageId(byte[] message_id) throws AQException
Parameter | Meaning |
---|---|
|
message id |
This method gets the correlation id.
public java.lang.String getCorrelation() throws AQException
This method sets the correlation id.
public void setCorrelation(java.lang.String correlation) throws AQException
Parameter | Meaning |
---|---|
|
user-supplied information |
This interface contains methods for AQ messages with raw or object payloads.
This method gets the message id.
public byte[] getMessageId() throws AQException
This method gets the raw payload
public AQRawPayload getRawPayload() throws AQException
AQRawPayload
object
This method sets the raw payload. It throws AQException
if this is called on messages created from object type queues.
public void setRawPayload(AQRawPayload message_payload) throws AQException
Parameter | Meaning |
---|---|
message_payload |
|
This method gets the message properties
public AQMessageProperty getMessageProperty() throws AQException
AQMessageProperty
object
This method sets the message properties.
public void setMessageProperty(AQMessageProperty property) throws AQException
Parameter | Meaning |
---|---|
|
AQMessageProperty object |
The AQMessageProperty class contains information that is used by AQ to manage individual messages. The properties are set at enqueue time and their values are returned at dequeue time.
public static final int DELAY_NONE public static final int EXPIRATION_NEVER public static final int STATE_READY public static final int STATE_WAITING public static final int STATE_PROCESSED public static final int STATE_EXPIRED
This method creates the AQMessageProperty object with default property values.
public AQMessageProperty()
This method gets the message priority.
public int getPriority() throws AQException
This method sets the message priority.
public void setPriority(int priority) throws AQException
Parameter | Meaning |
---|---|
|
priority of the message; this can be any number, including negative number - a smaller number indicates a higher priority |
This method gets the delay value.
public int getDelay() throws AQException
This method sets delay value.
public void setDelay(int delay) throws AQException
Parameter | Meaning |
---|---|
|
the delay represents the number of seconds after which the message is available for dequeuing; with |
This method gets expiration value
public int getExpiration() throws AQException
This method sets expiration value
public void setExpiration(int expiration) throws AQException
Parameter | Meaning |
---|---|
|
the duration the message is available for dequeuing; this parameter is an offset from the delay; if |
This method gets correlation
public java.lang.String getCorrelation() throws AQException
This method sets correlation
public void setCorrelation(java.lang.String correlation) throws AQException
Parameter | Meaning |
---|---|
|
user-supplied information |
This method gets the number of attempts.
public int getAttempts() throws AQException
This method gets the recipient list.
public java.util.Vector getRecipientList() throws AQException
A vector of AQAgents
.This parameter is not returned to a consumer at dequeue time.
This method sets the recipient list.
public void setRecipientList(java.util.Vector r_list) throws AQException
Parameter | Meaning |
---|---|
|
vector of |
This method gets original message id.
public byte[] getOrigMessageId() throws AQException
This method gets the sender of the message.
public AQAgent getSender() throws AQException
This method sets the sender of the message.
public void setSender(AQAgent sender) throws AQException
Parameter | Meaning |
---|---|
sender |
AQAgent |
This method gets the exception queue name.
public java.lang.String getExceptionQueue() throws AQException
This method sets the exception queue name.
public void setExceptionQueue(java.lang.String queue) throws AQException
Parameter | Meaning |
---|---|
queue |
exception queue name |
This method gets the enqueue time.
public java.util.Date getEnqueueTime() throws AQException
This method gets the message state.
public int getState() throws AQException
STATE_READY
or STATE_WAITING
or STATE_PROCESSED
or STATE_EXPIRED
This object represents the raw user data that is included in AQMessage.
This method reads some portion of the raw payload data into the specified byte array.
public int getStream(byte[] value, int len) throws AQException
Parameter | Meaning |
---|---|
|
byte array to hold the raw data |
|
number of bytes to be read |
The number of bytes read
This method retrieves the entire raw payload data as a byte array.
public byte[] getBytes() throws AQException
byte[] - the raw payload as a byte array
This method sets the value of the raw payload.
public void setStream(byte[] value, int len) throws AQException
Parameter | Meaning |
---|---|
|
byte array containing the raw payload |
|
number of bytes to be written to the raw stream |
This exception is raised when the user encounters any error while using the Java AQ Api.
public class AQException extends java.lang.RuntimeException
This interface supports all methods supported by Java exceptions and some additional methods.
This method gets the error message.
This method gets the error number (Oracle error code).
This method gets the next exception in the chain if any.
AQOracleSQLException
extends AQException
.
When using Oracle8i AQ driver, some errors may be raised from the client side and some from the RDBMS. The Oracle8i driver raises AQOracleSQLException
for all errors that ocuur while performing SQL.
For sophisticated users interested in differentiating between the two types of exceptions, this interface might be useful. In general you will only use AQException
.