Skip to content

Commit b12f100

Browse files
committed
Fix AQ section typos and then do a bit more....
1 parent 9ed6ea1 commit b12f100

File tree

1 file changed

+56
-41
lines changed

1 file changed

+56
-41
lines changed

doc/api.md

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ For installation information, see the [Node-oracledb Installation Instructions][
446446
24. [Statement Caching](#stmtcache)
447447
25. [Continuous Query Notification (CQN)](#cqn)
448448
26. [Oracle Advanced Queuing (AQ)](#aq)
449-
- 26.1 [Sending Simple AQ Messages](#aqexample)
449+
- 26.1 [Sending Simple AQ Messages](#aqrawexample)
450450
- 26.2 [Sending Oracle Database Object AQ Messages](#aqobjexample)
451451
- 26.3 [Changing AQ options](#aqoptions)
452452
- 26.4 [Enqueuing and Dequeuing Multiple Messages](#aqmultiplemessages)
@@ -4276,7 +4276,7 @@ some attributes controlling the behavior of the queued message.
42764276
`delay` | The number of seconds to delay the message before it can be dequeued.
42774277
`exceptionQueue` | A string containing the name of an exception queue in which to place the message if an exception takes place.
42784278
`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.
42804280
`priority` | An integer priority of the message.
42814281
42824282
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.
1221212212
Oracle Advanced Queuing allows applications to use producer-consumer
1221312213
message passing. Queuing is highly configurable and scalable,
1221412214
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].
1222112221
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.
1222412224
1222512225
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).
1222812235
1222912236
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:
1223312241
1223412242
```sql
1223512243
CREATE USER demoqueue IDENTIFIED BY &password;
@@ -12241,9 +12249,10 @@ GRANT EXECUTE ON DBMS_AQ TO demoqueue;
1224112249
1224212250
When you have finished testing, remove the DEMOQUEUE schema.
1224312251
12244-
### <a name="aqexample"></a> 26.1 Sending Simple AQ Messages
12252+
### <a name="aqrawexample"></a> 26.1 Sending Simple AQ Messages
1224512253
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:
1224712256
1224812257
```sql
1224912258
-- Create and start a queue
@@ -12262,7 +12271,7 @@ END;
1226212271
/
1226312272
```
1226412273
12265-
To enqueue a single, simple message, you could run:
12274+
To enqueue a single, simple message, run:
1226612275
1226712276
```javascript
1226812277
const queueName = "DEMO_RAW_QUEUE";
@@ -12271,24 +12280,27 @@ await queue.enqOne("This is my message");
1227112280
await connection.commit();
1227212281
```
1227312282
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:
1227512289
1227612290
```javascript
1227712291
const queueName = "DEMO_RAW_QUEUE";
1227812292
const queue = await connection.getQueue(queueName);
1227912293
const msg = await queue.deqOne();
1228012294
await connection.commit();
12281-
if (msg) {
12282-
console.log(msg.payload.toString());
12283-
}
12295+
console.log(msg.payload.toString());
1228412296
```
1228512297
1228612298
By default, `deqOne()` will wait until a message is available.
1228712299
1228812300
The variable `msg` is returned as an [AqMessage
1228912301
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`.
1229212304
1229312305
See [`examples/aqraw.js`][142] for a runnable example.
1229412306
@@ -12326,17 +12338,17 @@ END;
1232612338
/
1232712339
```
1232812340
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.
1233112343
12332-
In node-oracledb, a queue is initialized for the database object type:
12344+
In node-oracledb, a queue is initialized for that type:
1233312345
1233412346
```javascript
1233512347
const queueName = "ADDR_QUEUE";
1233612348
const queue = await connection.getQueue(queueName, {payloadType: "DEMOQUEUE.USER_ADDRESS_TYPE"});
1233712349
```
1233812350
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
1234012352
the type.
1234112353
1234212354
A [DbObject](#dbobjectclass) for the message is created and queued:
@@ -12365,10 +12377,8 @@ By default, `deqOne()` will wait until a message is available.
1236512377
The message can be printed:
1236612378
1236712379
```javascript
12368-
if (msg) {
12369-
const o = msg.payload;
12370-
console.log(o);
12371-
}
12380+
const o = msg.payload;
12381+
console.log(o);
1237212382
```
1237312383
1237412384
See [`examples/aqobjects.js`][143] for a runnable example.
@@ -12378,21 +12388,19 @@ See [`examples/aqobjects.js`][143] for a runnable example.
1237812388
The [AqQueue](#aqqueueclass) object created by calling
1237912389
[`connection.getQueue()`](#getqueue) contains
1238012390
[`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
1238212392
changed before each enqueue or dequeue call.
1238312393
1238412394
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:
1238812400
1238912401
```javascript
1239012402
const message = {
12391-
// correlation: "MyCorrelation",
12392-
// delay: 1,
12393-
// exceptionQueue: "MyExceptionQueue",
1239412403
expiration: 5,
12395-
// priority: 10,
1239612404
payload: "This is my message"
1239712405
};
1239812406

@@ -12402,6 +12410,9 @@ await queue.enqOne(message);
1240212410
await connection.commit();
1240312411
```
1240412412
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+
1240512416
To change the enqueue behavior of a queue, alter the
1240612417
[`enqOptions`](#aqqueueenqopts) attributes. For example to make a
1240712418
message buffered, and not persistent:
@@ -12451,7 +12462,7 @@ Object.assign(queue.deqOptions,
1245112462
1245212463
See [`examples/aqoptions.js`][144] for a runnable example.
1245312464
12454-
### <a name="aqmultiplemessages"></a> 24.4 Enqueuing and Dequeuing Multiple Messages
12465+
### <a name="aqmultiplemessages"></a> 26.4 Enqueuing and Dequeuing Multiple Messages
1245512466
1245612467
Enqueuing multiple messages in one operation is similar to the basic
1245712468
examples. However, instead of passing a single message to
@@ -12533,6 +12544,10 @@ await connection.close();
1253312544
See [Continuous Query Notification (CQN)](#cqn) for more information
1253412545
about subscriptions and notifications.
1253512546
12547+
AQ notifications require the same configuration as CQN. Specifically
12548+
the database must be able to connect back to node-oracledb.
12549+
12550+
1253612551
## <a name="nls"></a> 27. Globalization and National Language Support (NLS)
1253712552
1253812553
Node-oracledb can use Oracle's [National Language Support (NLS)][68]

0 commit comments

Comments
 (0)