1
1
.. _aq :
2
2
3
- **********************************
4
- Using Oracle Advanced Queuing (AQ)
5
- **********************************
6
-
7
- Oracle Advanced Queuing allows applications to use producer-consumer
8
- message passing. Queuing is highly configurable and scalable, providing
9
- a great way to distribute workloads. Messages can be queued by multiple
10
- producers. Different consumers can filter messages. Messages can also be
11
- transformed or propagated to queues in other databases. Oracle AQ is
12
- available in all editions of the database, and has interfaces in many
13
- languages, allowing different applications to communicate. For more
14
- details about AQ and its options, refer to the `Oracle Advanced Queuing
15
- User’s Guide <https://www.oracle.com/pls/topic/lookup?ctx=
16
- dblatest&id=ADQUE> `__.
3
+ ************************************************************
4
+ Using Oracle Transactional Event Queues and Advanced Queuing
5
+ ************************************************************
6
+
7
+ `Oracle Transactional Event Queues and Advanced Queuing <https://www.oracle.
8
+ com/pls/topic/lookup?ctx=dblatest&id=ADQUE> `__ are highly configurable and
9
+ scalable messaging features of Oracle Database, providing a great way to
10
+ distribute workloads. They allow applications to use producer-consumer message
11
+ passing. Messages can be queued by multiple producers. Different consumers can
12
+ filter messages. Messages can also be transformed or propagated to queues in
13
+ other databases. Oracle Transactional Event Queues (TxEventQ) and Advanced
14
+ Queuing (AQ) "Classic" queues have interfaces in many languages, allowing
15
+ different applications to communicate. Both TxEventQ and AQ queues support
16
+ sending and receiving of various payloads, such as RAW values, JSON, JMS, and
17
+ objects. TxEventQ queues use a highly optimized implementation of Advanced
18
+ Queuing. They were previously called AQ Sharded Queues.
17
19
18
20
.. note ::
19
21
20
- In this release, Oracle AQ is only supported in node-oracledb Thick mode.
21
- See :ref: `enablingthick `.
22
+ In this release, TxEventQ and AQ classic queues are only supported in
23
+ node-oracledb Thick mode. See :ref: `enablingthick `.
22
24
23
- Node-oracledb APIs for AQ were introduced in node-oracledb 4.0. With
24
- earlier versions, use AQ’s PL/SQL interface.
25
+ The same node-oracledb APIs are used for TxEventQ and AQ classic queues and
26
+ were introduced in node-oracledb 4.0. With earlier versions, use AQ’s PL/SQL
27
+ interface.
25
28
26
- Oracle Advanced Queues are represented in node-oracledb by several
27
- classes. A single top level :ref: `AqQueue object <aqqueueclass >` in
29
+ Both TxEventQ and AQ classic queues are represented in node-oracledb by
30
+ several classes. A single top level :ref: `AqQueue object <aqqueueclass >` in
28
31
node-oracledb contains :attr: `aqQueue.deqOptions ` and
29
32
:attr: `aqQueue.enqOptions ` object properties which can be used
30
- to change queue behavior. A single AqQueue object can be used for
31
- enqueuing, or dequeuing, or both at the same time.
33
+ to change queue behavior. TxEventQ queues do not support the
34
+ ``transformation `` attribute of :attr: `aqQueue.enqOptions ` and
35
+ :attr: `aqQueue.deqOptions ` properties, and
36
+ :ref: `Recipient Lists <aqrecipientlists >`. A single AqQueue object can be
37
+ used for enqueuing, or dequeuing, or both at the same time.
32
38
33
39
Messages are enqueued by passing them to an enqueue method directly, or
34
40
by wrapping them in a :meth: `JavaScript object <aqQueue.enqOne()> `. Dequeued
35
41
messages are returned as an :ref: `AqMessage object <aqmessageclass >`.
36
42
37
- The following examples show how to enqueue and dequeue messages in
38
- node-oracledb. Before using a queue in node-oracledb, it must be created
39
- in the database using the DBMS_AQADM PL/SQL package. For these examples,
43
+ There are differences in the payload types supported by TxEventQ and AQ
44
+ classic queues as detailed below.
45
+
46
+ **Classic Advanced Queuing (AQ) Support **
47
+
48
+ - RAW, named Oracle objects, and JMS payloads are supported.
49
+
50
+ - The JSON payload requires Oracle Client libraries 21c (or later) and Oracle
51
+ Database 21c (or later).
52
+
53
+ There are examples of AQ Classic Queues in the `GitHub examples
54
+ <https://github.com/oracle/node-oracledb/tree/main/examples> `__ directory.
55
+
56
+ **Transactional Event Queue (TxEventQ) Support **
57
+
58
+ - RAW and named Oracle object payloads are supported for single and array
59
+ message enqueuing and dequeuing when using Oracle Client 19c (or later) and
60
+ connected to Oracle Database 19c (or later).
61
+
62
+ - JMS payloads are supported for single and array message enqueuing and
63
+ dequeuing when using Oracle Client 19c (or later) and Oracle Database 23ai.
64
+
65
+ - JSON payloads are supported for single message enqueuing and dequeuing when
66
+ using Oracle Client libraries 21c (or later) and Oracle Database 21c (or
67
+ later). Array enqueuing and dequeuing is not supported for JSON payloads.
68
+
69
+ Before using a queue in node-oracledb, it must be created in the database
70
+ using the DBMS_AQADM PL/SQL package. For these examples,
40
71
create a new Oracle user ``demoqueue `` with permission to create and use
41
72
queues. Connect in SQL*Plus as SYSDBA and run:
42
73
@@ -55,8 +86,8 @@ When you have finished testing, remove the DEMOQUEUE schema.
55
86
Sending Simple AQ Messages
56
87
==========================
57
88
58
- You can use AQ to send RAW payloads by using a String or Buffer as the
59
- message.
89
+ You can use TxEventQ and classic AQ queues to send RAW payloads by using a
90
+ String or Buffer as the message.
60
91
61
92
Before enqueuing and dequeuing messages, you need to create and start queues
62
93
in Oracle Database. For example, to create a queue for simple messaging, use
@@ -91,6 +122,16 @@ attribute to ``oracledb.DB_TYPE_RAW`` in :meth:`connection.getQueue()`::
91
122
92
123
connection.getQueue(queueName, { payloadType: oracledb.DB_TYPE_RAW });
93
124
125
+ To create a Transactional Event Queue for RAW payloads:
126
+
127
+ .. code-block :: sql
128
+
129
+ BEGIN
130
+ DBMS_AQADM.CREATE_SHARDED_QUEUE('RAW_SHQ', QUEUE_PAYLOAD_TYPE=>'RAW');
131
+ DBMS_AQADM.START_QUEUE('RAW_SHQ');
132
+ END;
133
+ /
134
+
94
135
To enqueue a single, simple message, run:
95
136
96
137
.. code-block :: javascript
@@ -170,12 +211,12 @@ This will print an identifier like::
170
211
Sending Oracle Database JSON AQ Messages
171
212
========================================
172
213
173
- Starting from Oracle Database 21c, Advanced Queuing supports the JSON
174
- payloads. To use this payload type, the Oracle Client libraries must also be
175
- version 21 or later.
214
+ Starting from Oracle Database 21c, Transactional Event Queues (TxEventQ) and
215
+ classic Advanced Queuing (AQ) support JSON payloads. To use this payload type,
216
+ Oracle Client libraries must also be version 21 or later.
176
217
177
- You can use AQ to send JSON payloads by using a JavaScript object as the
178
- message.
218
+ You can use TxEventQ and classic AQ to send JSON payloads by using a
219
+ JavaScript object as the message.
179
220
180
221
Before enqueuing and dequeuing messages, you need to create and start queues
181
222
in Oracle Database. For example, to create a queue suitable for sending JSON
@@ -650,6 +691,9 @@ This prints::
650
691
5. empName : Employee #3
651
692
6. empId : 103
652
693
694
+ Transactional event queues do not support array enqueuing and dequeuing for
695
+ JSON payloads.
696
+
653
697
.. _aqnotifications :
654
698
655
699
Advanced Queuing Notifications
@@ -699,11 +743,12 @@ database must be able to connect back to node-oracledb.
699
743
Recipient Lists
700
744
===============
701
745
702
- A list of recipient names can be associated with a message at the time a
703
- message is enqueued. This allows a limited set of recipients to dequeue
704
- each message. The recipient list associated with the message overrides
705
- the queue subscriber list, if there is one. The recipient names need not
706
- be in the subscriber list but can be, if desired.
746
+ AQ Classic Queues support Recipient Lists. A list of recipient names can be
747
+ associated with a message at the time a message is enqueued. This allows a
748
+ limited set of recipients to dequeue each message. The recipient list
749
+ associated with the message overrides the queue subscriber list, if there is
750
+ one. The recipient names need not be in the subscriber list but can be, if
751
+ desired.
707
752
708
753
To dequeue a message, the ``consumerName `` attribute can be set to one
709
754
of the recipient names. The original message recipient list is not
0 commit comments