@@ -446,7 +446,7 @@ For installation information, see the [Node-oracledb Installation Instructions][
446
446
24 . [ Statement Caching] ( #stmtcache )
447
447
25 . [ Continuous Query Notification (CQN)] ( #cqn )
448
448
26 . [ Oracle Advanced Queuing (AQ)] ( #aq )
449
- - 26.1 [ Sending Simple AQ Messages] ( #aqexample )
449
+ - 26.1 [ Sending Simple AQ Messages] ( #aqrawexample )
450
450
- 26.2 [ Sending Oracle Database Object AQ Messages] ( #aqobjexample )
451
451
- 26.3 [ Changing AQ options] ( #aqoptions )
452
452
- 26.4 [ Enqueuing and Dequeuing Multiple Messages] ( #aqmultiplemessages )
@@ -4276,7 +4276,7 @@ some attributes controlling the behavior of the queued message.
4276
4276
`delay` | The number of seconds to delay the message before it can be dequeued.
4277
4277
`exceptionQueue` | A string containing the name of an exception queue in which to place the message if an exception takes place.
4278
4278
`expiration` | The number of seconds the message is available to be dequeued before it expires.
4279
- `payload` | A String, Buffer or DbObject that is the actual message to be queued. This property must be specified.
4279
+ `payload` | A String, Buffer or [ DbObject](#dbobjectclass) that is the actual message to be queued. This property must be specified.
4280
4280
`priority` | An integer priority of the message.
4281
4281
4282
4282
See [Oracle Advanced Queuing Documentation][129] for more information about attributes.
@@ -12212,24 +12212,32 @@ There are runnable examples in the GitHub [examples][3] directory.
12212
12212
Oracle Advanced Queuing allows applications to use producer-consumer
12213
12213
message passing. Queuing is highly configurable and scalable,
12214
12214
providing a great way to distribute workloads. Messages can be queued
12215
- by multiple producers. Different consumers can filter messages for
12216
- them. Messages can also be transformed or propagated to queues in
12217
- other databases. Oracle AQ is available in all editions of the
12218
- database, and has interfaces in many languages, allowing different
12219
- applications to communicate. For more details about AQ and its
12220
- options, refer to the [Oracle Advanced Queuing User's Guide][129].
12215
+ by multiple producers. Different consumers can filter messages.
12216
+ Messages can also be transformed or propagated to queues in other
12217
+ databases. Oracle AQ is available in all editions of the database,
12218
+ and has interfaces in many languages, allowing different applications
12219
+ to communicate. For more details about AQ and its options, refer to
12220
+ the [Oracle Advanced Queuing User's Guide][129].
12221
12221
12222
- Native AQ support was added in node-oracledb 4.0. With earlier
12223
- versions, use AQ's PL/SQL interface.
12222
+ Node-oracledb APIs for AQ were introduced in node-oracledb 4.0. With
12223
+ earlier versions, use AQ's PL/SQL interface.
12224
12224
12225
12225
Oracle Advanced Queues are represented in node-oracledb by several
12226
- classes, described below. Before using a queue in node-oracledb, it
12227
- must be created in the database using the DBMS_AQADM PL/SQL package.
12226
+ classes. A single top level [AqQueue object](#aqqueueclass) in
12227
+ node-oracledb contains [` deqOptions` ](#aqqueuedeqopts) and
12228
+ [` enqOptions` ](#aqqueueenqopts) object properties which can be used to
12229
+ change queue behavior. A single AqQueue object can be used for
12230
+ enqueuing, or dequeuing, or both at the same time.
12231
+
12232
+ Messages are enqueued by passing them to an enqueue method directly,
12233
+ or by wrapping them in a [JavaScript object](#aqjsmessage). Dequeued
12234
+ messages are returned as an [AqMessage object](#aqmessageclass).
12228
12235
12229
12236
The following examples show how to enqueue and dequeue messages in
12230
- node-oracledb. For these examples, create a new Oracle user
12231
- ` demoqueue` with permission to create and use queues. Connect in
12232
- SQL*Plus as SYSDBA and run:
12237
+ node-oracledb. Before using a queue in node-oracledb, it must be
12238
+ created in the database using the DBMS_AQADM PL/SQL package. For
12239
+ these examples, create a new Oracle user ` demoqueue` with permission
12240
+ to create and use queues. Connect in SQL*Plus as SYSDBA and run:
12233
12241
12234
12242
` ` ` sql
12235
12243
CREATE USER demoqueue IDENTIFIED BY & password;
@@ -12241,9 +12249,10 @@ GRANT EXECUTE ON DBMS_AQ TO demoqueue;
12241
12249
12242
12250
When you have finished testing, remove the DEMOQUEUE schema.
12243
12251
12244
- ### <a name="aqexample "></a> 26.1 Sending Simple AQ Messages
12252
+ ### <a name="aqrawexample "></a> 26.1 Sending Simple AQ Messages
12245
12253
12246
- To create a queue for simple messaging:
12254
+ To create a queue for simple messaging, use SQL*Plus to connect as the
12255
+ new DEMOQUEUE user and run:
12247
12256
12248
12257
` ` ` sql
12249
12258
-- Create and start a queue
@@ -12262,7 +12271,7 @@ END;
12262
12271
/
12263
12272
` ` `
12264
12273
12265
- To enqueue a single, simple message, you could run:
12274
+ To enqueue a single, simple message, run:
12266
12275
12267
12276
` ` ` javascript
12268
12277
const queueName = " DEMO_RAW_QUEUE" ;
@@ -12271,24 +12280,27 @@ await queue.enqOne("This is my message");
12271
12280
await connection .commit ();
12272
12281
` ` `
12273
12282
12274
- An application could dequeue a message by running:
12283
+ Messages can be passed directly to ` enqOne ()` as shown above.
12284
+ Alternatively they can be the ` payload` property of a JavaScript
12285
+ object passed to ` enqOne ()` , as shown in [Changing AQ
12286
+ options](#aqoptions).
12287
+
12288
+ To dequeue a message, run:
12275
12289
12276
12290
` ` ` javascript
12277
12291
const queueName = " DEMO_RAW_QUEUE" ;
12278
12292
const queue = await connection .getQueue (queueName);
12279
12293
const msg = await queue .deqOne ();
12280
12294
await connection .commit ();
12281
- if (msg) {
12282
- console .log (msg .payload .toString ());
12283
- }
12295
+ console .log (msg .payload .toString ());
12284
12296
` ` `
12285
12297
12286
12298
By default, ` deqOne ()` will wait until a message is available.
12287
12299
12288
12300
The variable ` msg` is returned as an [AqMessage
12289
12301
object](#aqmessageclass) which contains the message payload and other
12290
- metadata. Note that string messages are encoded as UTF-8 Buffers.
12291
- This example displays ` This is my message` .
12302
+ metadata. String messages are encoded as UTF-8 Buffers. This example
12303
+ displays ` This is my message` .
12292
12304
12293
12305
See [` examples/ aqraw .js ` ][142] for a runnable example.
12294
12306
@@ -12326,17 +12338,17 @@ END;
12326
12338
/
12327
12339
` ` `
12328
12340
12329
- In the [previous section](#aqexample ) the ` QUEUE_PAYLOAD_TYPE ` was 'RAW'
12330
- but here the object type name ` DEMOQUEUE .USER_ADDRESS_TYPE ` is used.
12341
+ In the [previous section](#aqrawexample ) the ` QUEUE_PAYLOAD_TYPE ` was 'RAW'
12342
+ but here the Oracle Database object type name ` DEMOQUEUE .USER_ADDRESS_TYPE ` is used.
12331
12343
12332
- In node-oracledb, a queue is initialized for the database object type:
12344
+ In node-oracledb, a queue is initialized for that type:
12333
12345
12334
12346
` ` ` javascript
12335
12347
const queueName = " ADDR_QUEUE" ;
12336
12348
const queue = await connection .getQueue (queueName, {payloadType: " DEMOQUEUE.USER_ADDRESS_TYPE" });
12337
12349
` ` `
12338
12350
12339
- For efficiencey , it is recommended to use a fully qualified name for
12351
+ For efficiency , it is recommended to use a fully qualified name for
12340
12352
the type.
12341
12353
12342
12354
A [DbObject](#dbobjectclass) for the message is created and queued:
@@ -12365,10 +12377,8 @@ By default, `deqOne()` will wait until a message is available.
12365
12377
The message can be printed:
12366
12378
12367
12379
` ` ` javascript
12368
- if (msg) {
12369
- const o = msg .payload ;
12370
- console .log (o);
12371
- }
12380
+ const o = msg .payload ;
12381
+ console .log (o);
12372
12382
` ` `
12373
12383
12374
12384
See [` examples/ aqobjects .js ` ][143] for a runnable example.
@@ -12378,21 +12388,19 @@ See [`examples/aqobjects.js`][143] for a runnable example.
12378
12388
The [AqQueue](#aqqueueclass) object created by calling
12379
12389
[` connection .getQueue ()` ](#getqueue) contains
12380
12390
[` enqOptions` ](#aqqueueenqopts) and [` deqOptions` ](#aqqueuedeqopts)
12381
- attribute options that can be configured. These options can be
12391
+ attribute objects that can be configured. These options can be
12382
12392
changed before each enqueue or dequeue call.
12383
12393
12384
12394
Messages that are enqueued can also contain properties, such as an
12385
- expiration. For example to expire a message after 5 seconds if it
12386
- hasn't been dequeued, you can enqueue a message in a [JavaScript
12387
- object](#aqjsmessage) like:
12395
+ expiration. Instead of passing a message String, Buffer or DbObject
12396
+ directly to ` enqOne ()` , a ` payload` property of a [JavaScript
12397
+ object](#aqjsmessage) is set to the message. Other object properties
12398
+ control the message behavior. For example to expire a message after
12399
+ five seconds if it hasn't been dequeued:
12388
12400
12389
12401
` ` ` javascript
12390
12402
const message = {
12391
- // correlation: "MyCorrelation",
12392
- // delay: 1,
12393
- // exceptionQueue: "MyExceptionQueue",
12394
12403
expiration: 5 ,
12395
- // priority: 10,
12396
12404
payload: " This is my message"
12397
12405
};
12398
12406
@@ -12402,6 +12410,9 @@ await queue.enqOne(message);
12402
12410
await connection .commit ();
12403
12411
` ` `
12404
12412
12413
+ For RAW queues the ` payload` value can be a String or Buffer. For
12414
+ object queues ` payload` can be a [DbObject](#dbobjectclass) object.
12415
+
12405
12416
To change the enqueue behavior of a queue, alter the
12406
12417
[` enqOptions` ](#aqqueueenqopts) attributes. For example to make a
12407
12418
message buffered, and not persistent:
@@ -12451,7 +12462,7 @@ Object.assign(queue.deqOptions,
12451
12462
12452
12463
See [` examples/ aqoptions .js ` ][144] for a runnable example.
12453
12464
12454
- ### <a name="aqmultiplemessages"></a> 24 .4 Enqueuing and Dequeuing Multiple Messages
12465
+ ### <a name="aqmultiplemessages"></a> 26 .4 Enqueuing and Dequeuing Multiple Messages
12455
12466
12456
12467
Enqueuing multiple messages in one operation is similar to the basic
12457
12468
examples. However, instead of passing a single message to
@@ -12533,6 +12544,10 @@ await connection.close();
12533
12544
See [Continuous Query Notification (CQN)](#cqn) for more information
12534
12545
about subscriptions and notifications.
12535
12546
12547
+ AQ notifications require the same configuration as CQN. Specifically
12548
+ the database must be able to connect back to node-oracledb.
12549
+
12550
+
12536
12551
## <a name="nls"></a> 27. Globalization and National Language Support (NLS)
12537
12552
12538
12553
Node-oracledb can use Oracle's [National Language Support (NLS)][68]
0 commit comments