Skip to content

Commit 732e7d6

Browse files
AQ doc updates.
1 parent 60225f6 commit 732e7d6

File tree

2 files changed

+91
-56
lines changed

2 files changed

+91
-56
lines changed

doc/src/user_guide/appendix_a.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ see :ref:`driverdiff` and :ref:`compatibility`.
250250
- No
251251
- Yes
252252
- Yes
253-
* - Advanced Queuing (AQ) (see :ref:`aqusermanual`)
253+
* - Oracle Transactional Event Queues and Advanced Queuing (AQ) (see :ref:`aqusermanual`)
254254
- No
255-
- Yes - must use new API introduced in cx_Oracle 7.2
255+
- Yes
256256
- Yes
257257
* - Call timeouts (see :attr:`Connection.call_timeout`)
258258
- Yes

doc/src/user_guide/aq.rst

+89-54
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,64 @@
11
.. _aqusermanual:
22

3-
***********************************
4-
Using Oracle Advanced Queuing (AQ)
5-
***********************************
6-
7-
`Oracle Advanced Queuing
8-
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=ADQUE>`__ is a highly
9-
configurable and scalable messaging feature of Oracle Database. It has
10-
interfaces in various languages, letting you integrate multiple tools in your
11-
architecture.
3+
************************************************************
4+
Using Oracle Transactional Event Queues and Advanced Queuing
5+
************************************************************
6+
7+
`Oracle Transactional Event Queues and Advanced Queuing
8+
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=ADQUE>`__ are highly
9+
configurable and scalable messaging features of Oracle Database allowing
10+
data-driven and event-driven applications to stream events and communicate with
11+
each other. They have interfaces in various languages, letting you integrate
12+
multiple tools in your architecture. Both Oracle Transactional Event Queues
13+
(TxEventQ) and Advanced Queuing (AQ) "Classic" queues support sending and
14+
receiving of various payloads, such as RAW values, JSON, JMS, and objects.
15+
Transactional Event Queues use a highly optimized implementation of Advanced
16+
Queuing. They were previously called AQ Sharded Queues.
1217

1318
.. note::
1419

15-
Oracle Advanced Queuing is only supported in the python-oracledb Thick
20+
TxEventQ and AQ Classic queues are only supported in python-oracledb Thick
1621
mode. See :ref:`enablingthick`.
1722

18-
Python-oracledb uses the updated interface for Oracle Advanced Queuing that
19-
was first introduced in cx_Oracle 7.2.
23+
Python-oracledb API calls are the same for Transactional Event Queues and
24+
Classic Queues, however there are differences in support for some payload
25+
types.
26+
27+
**Classic Queue Support**
28+
29+
- RAW, named Oracle objects, and JMS payloads are supported.
2030

21-
Starting from Oracle Database 21c, Advanced Queuing also supports the JSON
22-
payload type. To use the JSON payload type, the Oracle Client libraries must
23-
be version 21 or later.
31+
- The JSON payload requires Oracle Client libraries 21c (or later) and Oracle
32+
Database 21c (or later).
2433

25-
There are Advanced Queuing examples in the `GitHub examples
34+
There are examples of AQ Classic Queues in the `GitHub examples
2635
<https://github.com/oracle/python-oracledb/tree/main/samples>`__ directory.
2736

37+
**Transactional Event Queue Support**
38+
39+
- RAW and named Oracle object payloads are supported for single and array
40+
message enqueuing and dequeuing when using Oracle Client 19c (or later) and
41+
connected to Oracle Database 19c (or later).
42+
43+
- JMS payloads are supported for single and array message enqueuing and
44+
dequeuing when using Oracle Client 19c (or later) and Oracle Database 23ai.
45+
46+
- JSON payloads are supported for single message enqueuing and dequeuing when
47+
using Oracle Client libraries 21c (or later) and Oracle Database 21c (or
48+
later). Array enqueuing and dequeuing is not supported for JSON payloads.
49+
50+
Transactional Event Queues do not support :attr:`EnqOptions.transformation`,
51+
:attr:`DeqOptions.transformation`, or :ref:`Recipient Lists <reciplists>`.
2852

2953
Creating a Queue
3054
================
3155

32-
Before being used, queues need to be created in the database.
56+
Before being used in applications, queues need to be created in the database.
3357

3458
**Using RAW Payloads**
3559

36-
Queues can be created using the RAW payload type, for example in
37-
SQL*Plus:
60+
To use SQL*Plus to create a Classic Queue for the RAW payload which is suitable
61+
for sending string or bytes messages:
3862

3963
.. code-block:: sql
4064
@@ -45,13 +69,20 @@ SQL*Plus:
4569
end;
4670
/
4771
48-
This example creates a RAW queue suitable for sending string or bytes
49-
messages.
72+
To create a Transactional Event Queue for RAW payloads:
73+
74+
.. code-block:: sql
75+
76+
begin
77+
dbms_aqadm.create_sharded_queue('RAW_SHQ', queue_payload_type=>'RAW');
78+
dbms_aqadm.start_queue('RAW_SHQ');
79+
end;
80+
/
5081
5182
**Using JSON Payloads**
5283

53-
Also, queues can be created using the JSON payload type. For example,
54-
in SQL*Plus:
84+
Queues can also be created for JSON payloads. For example, to create a Classic
85+
Queue in SQL*Plus:
5586

5687
.. code-block:: sql
5788
@@ -62,14 +93,11 @@ in SQL*Plus:
6293
end;
6394
/
6495
65-
This example creates a JSON queue suitable for sending JSON data
66-
messages.
67-
6896
Enqueuing Messages
6997
==================
7098

7199
To send messages in Python, you connect and get a :ref:`queue <queue>`. The
72-
queue can be used for enqueuing, dequeuing, or both as needed.
100+
queue can then be used for enqueuing, dequeuing, or for both.
73101

74102
**Using RAW Payloads**
75103

@@ -94,9 +122,12 @@ messages:
94122
queue.enqone(connection.msgproperties(payload=data))
95123
connection.commit()
96124
97-
Since the queue sending the messages is a RAW queue, the strings in this
98-
example will be internally encoded to bytes using ``message.encode()``
99-
before being enqueued.
125+
Since the queue is a RAW queue, strings are internally encoded to bytes using
126+
``message.encode()`` before being enqueued.
127+
128+
The use of :meth:`~Connection.commit()` means that messages are sent only when
129+
any database transaction related to them is committed. This behavior can be
130+
altered, see :ref:`aqoptions`.
100131

101132
**Using JSON Payloads**
102133

@@ -105,8 +136,8 @@ payload type by using:
105136

106137
.. code-block:: python
107138
139+
# The argument "JSON" indicates the queue is of JSON payload type
108140
queue = connection.queue("DEMO_JSON_QUEUE", "JSON")
109-
# The second argument (JSON) indicates that the queue is of JSON payload type.
110141
111142
Now the message can be enqueued using :meth:`~Queue.enqone()`.
112143

@@ -133,7 +164,7 @@ Dequeuing Messages
133164
Dequeuing is performed similarly. To dequeue a message call the method
134165
:meth:`~Queue.deqone()` as shown in the examples below.
135166

136-
**Using RAW Payload Type**
167+
**Using RAW Payloads**
137168

138169
.. code-block:: python
139170
@@ -142,10 +173,10 @@ Dequeuing is performed similarly. To dequeue a message call the method
142173
connection.commit()
143174
print(message.payload.decode())
144175
145-
Note that if the message is expected to be a string, the bytes must
146-
be decoded using ``message.payload.decode()``, as shown.
176+
Note that if the message is expected to be a string, the bytes must be decoded
177+
by the application using ``message.payload.decode()``, as shown.
147178

148-
**Using JSON Payload Type**
179+
**Using JSON Payloads**
149180

150181
.. code-block:: python
151182
@@ -179,7 +210,7 @@ And a queue that accepts this type:
179210
end;
180211
/
181212
182-
You can queue messages:
213+
You can enqueue messages:
183214

184215
.. code-block:: python
185216
@@ -194,7 +225,7 @@ You can queue messages:
194225
queue.enqone(connection.msgproperties(payload=book))
195226
connection.commit()
196227
197-
Dequeuing is done like this:
228+
Dequeuing can be done like this:
198229

199230
.. code-block:: python
200231
@@ -205,18 +236,20 @@ Dequeuing is done like this:
205236
connection.commit()
206237
print(message.payload.TITLE) # will print Quick Brown Fox
207238
239+
.. _reciplists:
208240

209241
Using Recipient Lists
210242
=====================
211243

212-
A list of recipient names can be associated with a message at the time
213-
a message is enqueued. This allows a limited set of recipients to
214-
dequeue each message. The recipient list associated with the message
215-
overrides the queue subscriber list, if there is one. The recipient
216-
names need not be in the subscriber list but can be, if desired.
244+
Classic Queues support Recipient Lists. A list of recipient names can be
245+
associated with a message at the time a message is enqueued. This allows a
246+
limited set of recipients to dequeue each message. The recipient list
247+
associated with the message overrides the queue subscriber list, if there is
248+
one. The recipient names need not be in the subscriber list but can be, if
249+
desired. Transactional Event Queues do not support Recipient Lists.
217250

218-
To dequeue a message, the ``consumername`` attribute can be set to
219-
one of the recipient names. The original message recipient list is
251+
To dequeue a message, the :attr:`~DeqOptions.consumername` attribute can be
252+
set to one of the recipient names. The original message recipient list is
220253
not available on dequeued messages. All recipients have to dequeue
221254
a message before it gets removed from the queue.
222255

@@ -237,6 +270,8 @@ messages intended for that recipient using the ``consumername`` attribute::
237270
queue.deqoptions.consumername = "sub3"
238271
m = queue.deqone()
239272

273+
.. _aqoptions:
274+
240275
Changing Queue and Message Options
241276
==================================
242277

@@ -245,8 +280,8 @@ Refer to the :ref:`python-oracledb AQ API <aq>` and
245280
<https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=ADQUE>`__ for details
246281
on all of the enqueue and dequeue options available.
247282

248-
Enqueue options can be set. For example, to make it so that an explicit
249-
call to :meth:`~Connection.commit()` on the connection is not needed to commit
283+
Enqueue options can be set. For example, to make it so that an explicit call
284+
to :meth:`~Connection.commit()` on the connection is not needed to send
250285
messages:
251286

252287
.. code-block:: python
@@ -269,7 +304,7 @@ expiration of 60 seconds on a message:
269304
270305
queue.enqone(connection.msgproperties(payload="Message", expiration=60))
271306
272-
This means that if no dequeue operation occurs within 60 seconds that the
307+
This means that if no dequeue operation occurs within 60 seconds then the
273308
message will be dropped from the queue.
274309

275310

@@ -279,8 +314,8 @@ Bulk Enqueue and Dequeue
279314
The :meth:`~Queue.enqmany()` and :meth:`~Queue.deqmany()` methods can be used
280315
for efficient bulk message handling.
281316

282-
:meth:`~Queue.enqmany()` is similar to :meth:`~Queue.enqone()` but accepts an
283-
array of messages:
317+
The :meth:`~Queue.enqmany()` method is similar to :meth:`~Queue.enqone()` but
318+
accepts an array of messages:
284319

285320
.. code-block:: python
286321
@@ -296,11 +331,11 @@ array of messages:
296331
.. warning::
297332

298333
Calling :meth:`~Queue.enqmany()` in parallel on different connections
299-
acquired from the same pool may fail due to Oracle bug 29928074. Ensure
300-
that this function is not run in parallel, use standalone connections or
301-
connections from different pools, or make multiple calls to
302-
:meth:`~Queue.enqone()` instead. The function :meth:`~Queue.deqmany()` call
303-
is not affected.
334+
acquired from the same pool may fail due to Oracle bug 29928074. To avoid
335+
this, ensure that :meth:`~Queue.enqmany()` is not run in parallel, use
336+
standalone connections or connections from different pools, or make
337+
multiple calls to :meth:`~Queue.enqone()` instead. The function
338+
:meth:`~Queue.deqmany()` call is not affected.
304339

305340
To dequeue multiple messages at one time, use :meth:`~Queue.deqmany()`. This
306341
takes an argument specifying the maximum number of messages to dequeue at one

0 commit comments

Comments
 (0)