DEQUEUE¶
The DEQUEUE
procedure dequeues a message. The signature is:
DEQUEUE(
<queue_name> IN VARCHAR2,
<dequeue_options> IN DBMS_AQ.DEQUEUE_OPTIONS_T,
<message_properties> OUT DBMS_AQ.MESSAGE_PROPERTIES_T,
<payload> OUT <type_name>,
<msgid> OUT RAW)
Parameters
queue_name
The name (optionally schema-qualified) of an existing queue. If you omit the schema name, the server will use the schema specified in the
SEARCH_PATH
. Please note that unlike Oracle, unquoted identifiers are converted to lower case before storing. To include special characters or use a case-sensitive name, enclose the name in double quotes.For detailed information about creating a queue, see
DBMS_AQADM.CREATE_QUEUE
.
dequeue_options
dequeue_options
is a value of the type,dequeue_options_t
:DEQUEUE_OPTIONS_T IS RECORD( consumer_name CHARACTER VARYING(30), dequeue_mode INTEGER, navigation INTEGER, visibility INTEGER, wait INTEGER, msgid BYTEA, correlation CHARACTER VARYING(128), deq_condition CHARACTER VARYING(4000), transformation CHARACTER VARYING(61), delivery_mode INTEGER);Currently, the supported parameter values for
dequeue_options_t
are:
|
Must be |
|
The locking behavior of the dequeue operation. Must be either:
|
|
Identifies the message that will be retrieved. Must be either:
|
|
Must be |
|
Must be a number larger than 0, or:
|
|
The message ID of the message that will be dequeued. |
|
Accepted for compatibility, and ignored. |
|
A |
|
Accepted for compatibility, and ignored. |
|
Must be |
message_properties
message_properties
is a value of the type,message_properties_t
:message_properties_t IS RECORD( priority INTEGER, delay INTEGER, expiration INTEGER, correlation CHARACTER VARYING(128) COLLATE pg_catalog.”C”, attempts INTEGER, recipient_list “AQ$_RECIPIENT_LIST_T”, exception_queue CHARACTER VARYING(61) COLLATE pg_catalog.”C”, enqueue_time TIMESTAMP WITHOUT TIME ZONE, state INTEGER, original_msgid BYTEA, transaction_group CHARACTER VARYING(30) COLLATE pg_catalog.”C”, delivery_mode INTEGER DBMS_AQ.PERSISTENT);The supported values for
message_properties_t
are:
|
If the queue table definition includes a |
|
Specify the number of seconds that will pass before a message is available for dequeueing or |
|
Use the expiration parameter to specify the number of seconds until a message expires. |
|
Use correlation to specify a message that will be associated with the entry; the default is |
|
This is a system-maintained value that specifies the number of attempts to dequeue the message. |
|
This parameter is not supported. |
|
Use the |
|
|
|
This parameter is maintained by |
|
This parameter is accepted for compatibility and ignored. |
|
This parameter is accepted for compatibility and ignored. |
|
This parameter is not supported; specify a value of |
payload
Use the
payload
parameter to retrieve the payload of a message with a dequeue operation. The payload type must match the type specified when creating the queue table.
msgid
Use the
msgid
parameter to retrieve a unique message identifier.
Example
The following anonymous block calls DBMS_AQ.DEQUEUE
, retrieving a
message from the queue and a payload:
DECLARE
dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T;
message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
message_handle raw(16);
payload work_order;
BEGIN
dequeue_options.dequeue_mode := DBMS_AQ.BROWSE;
DBMS_AQ.DEQUEUE(
queue_name => 'work_queue',
dequeue_options => dequeue_options,
message_properties => message_properties,
payload => payload,
msgid => message_handle
);
DBMS_OUTPUT.PUT_LINE(
'The next work order is [' || payload.subject || '].'
);
END;
The payload is displayed by DBMS_OUTPUT.PUT_LINE
.