@@ -204,16 +204,17 @@ For installation information, see the [Node-oracledb Installation Instructions][
204
204
- 4.2.16.2 [`subscribe()`: Options](#consubscribeoptions)
205
205
- 4.2.16.2.1 [`binds`](#consubscribeoptbinds)
206
206
- 4.2.16.2.2 [`callback`](#consubscribeoptcallback)
207
- - 4.2.16.2.3 [`groupingClass`](#consubscribeoptgroupingclass)
208
- - 4.2.16.2.4 [`groupingType`](#consubscribeoptgroupingtype)
209
- - 4.2.16.2.5 [`groupingValue`](#consubscribeoptgroupingvalue)
210
- - 4.2.16.2.6 [`ipAddress`](#consubscribeoptipaddress)
211
- - 4.2.16.2.7 [`namespace`](#consubscribeoptnamespace)
212
- - 4.2.16.2.8 [`operations`](#consubscribeoptoperations)
213
- - 4.2.16.2.9 [`port`](#consubscribeoptport)
214
- - 4.2.16.2.10 [`qos`](#consubscribeoptqos)
215
- - 4.2.16.2.11 [`sql`](#consubscribeoptsql)
216
- - 4.2.16.2.12 [`timeout`](#consubscribeopttimeout)
207
+ - 4.2.16.2.3 [`clientInitiated`](#consubscribeoptclientinitiated)
208
+ - 4.2.16.2.4 [`groupingClass`](#consubscribeoptgroupingclass)
209
+ - 4.2.16.2.5 [`groupingType`](#consubscribeoptgroupingtype)
210
+ - 4.2.16.2.6 [`groupingValue`](#consubscribeoptgroupingvalue)
211
+ - 4.2.16.2.7 [`ipAddress`](#consubscribeoptipaddress)
212
+ - 4.2.16.2.8 [`namespace`](#consubscribeoptnamespace)
213
+ - 4.2.16.2.9 [`operations`](#consubscribeoptoperations)
214
+ - 4.2.16.2.10 [`port`](#consubscribeoptport)
215
+ - 4.2.16.2.11 [`qos`](#consubscribeoptqos)
216
+ - 4.2.16.2.12 [`sql`](#consubscribeoptsql)
217
+ - 4.2.16.2.13 [`timeout`](#consubscribeopttimeout)
217
218
- 4.2.16.3 [`subscribe()`: Callback Function](#consubscribecallback)
218
219
- 4.2.17 [`unsubscribe()`](#conunsubscribe)
219
220
5. [AqQueue Class](#aqqueueclass)
@@ -3946,7 +3947,23 @@ The `message` parameter in the notification callback is an object containing the
3946
3947
- [`oracledb.SUBSCR_EVENT_TYPE_OBJ_CHANGE`](#oracledbconstantssubscription) - object-level notifications are being used (Database Change Notification).
3947
3948
- [`oracledb.SUBSCR_EVENT_TYPE_QUERY_CHANGE`](#oracledbconstantssubscription) - query-level notifications are being used (Continuous Query Notification).
3948
3949
3949
- ###### <a name="consubscribeoptgroupingclass"></a> 4.2.16.2.3 `groupingClass`
3950
+ ###### <a name="consubscribeoptclientinitiated"></a> 4.2.16.2.3 `clientInitiated`
3951
+
3952
+ ```
3953
+ Boolean clientInitiated
3954
+ ```
3955
+
3956
+ This property enables CQN "client initiated" connections which internally use the same
3957
+ approach as normal connections to the database, and do not require the database
3958
+ to be able to connect back to the application. Since client initiated
3959
+ connections do not need additional network configuration, they have ease-of-use
3960
+ and security advantages.
3961
+
3962
+ The default is *false*.
3963
+
3964
+ This property was added in node-oracledb 4.2. It is available when Oracle Database and the Oracle client libraries are version 19.4 or higher.
3965
+
3966
+ ###### <a name="consubscribeoptgroupingclass"></a> 4.2.16.2.4 `groupingClass`
3950
3967
3951
3968
```
3952
3969
Number groupingClass
@@ -3957,7 +3974,7 @@ An integer mask which currently, if set, can only contain the value
3957
3974
this value is set then notifications are grouped by time into a single
3958
3975
notification.
3959
3976
3960
- ###### <a name="consubscribeoptgroupingtype"></a> 4.2.16.2.4 `groupingType`
3977
+ ###### <a name="consubscribeoptgroupingtype"></a> 4.2.16.2.5 `groupingType`
3961
3978
3962
3979
```
3963
3980
Number groupingType
3970
3987
[`oracledb.SUBSCR_GROUPING_TYPE_LAST`](#oracledbconstantssubscription)
3971
3988
indicating the last notification in the group should be sent.
3972
3989
3973
- ###### <a name="consubscribeoptgroupingvalue"></a> 4.2.16.2.5 `groupingValue`
3990
+ ###### <a name="consubscribeoptgroupingvalue"></a> 4.2.16.2.6 `groupingValue`
3974
3991
3975
3992
```
3976
3993
Number groupingValue
@@ -3982,7 +3999,7 @@ then `groupingValue` can be used to set the number of seconds over
3982
3999
which notifications will be grouped together, invoking `callback`
3983
4000
once. If `groupingClass` is not set, then `groupingValue` is ignored.
3984
4001
3985
- ###### <a name="consubscribeoptipaddress"></a> 4.2.16.2.6 `ipAddress`
4002
+ ###### <a name="consubscribeoptipaddress"></a> 4.2.16.2.7 `ipAddress`
3986
4003
3987
4004
```
3988
4005
String ipAddress
@@ -3992,7 +4009,7 @@ A string containing an IPv4 or IPv6 address on which the subscription
3992
4009
should listen to receive notifications. If not specified, then the
3993
4010
Oracle Client library will select an IP address.
3994
4011
3995
- ###### <a name="consubscribeoptnamespace"></a> 4.2.16.2.7 `namespace`
4012
+ ###### <a name="consubscribeoptnamespace"></a> 4.2.16.2.8 `namespace`
3996
4013
3997
4014
```
3998
4015
Number namespace
@@ -4007,7 +4024,7 @@ You can use `oracledb.SUBSCR_NAMESPACE_AQ` to get notifications that
4007
4024
Advanced Queuing messages are available to be dequeued, see
4008
4025
[Advanced Queuing Notifications](#aqnotifications).
4009
4026
4010
- ###### <a name="consubscribeoptoperations"></a> 4.2.16.2.8 `operations`
4027
+ ###### <a name="consubscribeoptoperations"></a> 4.2.16.2.9 `operations`
4011
4028
4012
4029
```
4013
4030
Number operations
@@ -4017,7 +4034,7 @@ An integer mask containing one or more of the operation type
4017
4034
[`oracledb.CQN_OPCODE_*`](#oracledbconstantscqn) constants to indicate
4018
4035
what types of database change should generation notifications.
4019
4036
4020
- ###### <a name="consubscribeoptport"></a> 4.2.16.2.9 `port`
4037
+ ###### <a name="consubscribeoptport"></a> 4.2.16.2.10 `port`
4021
4038
4022
4039
```
4023
4040
Number port
@@ -4027,7 +4044,7 @@ The port number on which the subscription should listen to receive
4027
4044
notifications. If not specified, then the Oracle Client library will
4028
4045
select a port number.
4029
4046
4030
- ###### <a name="consubscribeoptqos"></a> 4.2.16.2.10 `qos`
4047
+ ###### <a name="consubscribeoptqos"></a> 4.2.16.2.11 `qos`
4031
4048
4032
4049
```
4033
4050
Number qos
@@ -4036,15 +4053,15 @@ Number qos
4036
4053
An integer mask containing one or more of the quality of service
4037
4054
[`oracledb.SUBSCR_QOS_*`](#oracledbconstantssubscription) constants.
4038
4055
4039
- ###### <a name="consubscribeoptsql"></a> 4.2.16.2.11 `sql`
4056
+ ###### <a name="consubscribeoptsql"></a> 4.2.16.2.12 `sql`
4040
4057
4041
4058
```
4042
4059
String sql
4043
4060
```
4044
4061
4045
4062
The SQL query string to use for notifications.
4046
4063
4047
- ###### <a name="consubscribeopttimeout"></a> 4.2.16.2.12 `timeout`
4064
+ ###### <a name="consubscribeopttimeout"></a> 4.2.16.2.13 `timeout`
4048
4065
4049
4066
The number of seconds the subscription should remain active. Once
4050
4067
this length of time has been reached, the subscription is
@@ -12503,34 +12520,38 @@ satisfaction.
12503
12520
12504
12521
## <a name="cqn"></a> 25. Continuous Query Notification (CQN)
12505
12522
12506
- [Continuous Query Notification (CQN)][99] lets node-oracledb
12507
- applications register a JavaScript method that is invoked when changed
12508
- data is committed to the database, regardless of the user or the
12509
- application that made the change. For example your application may be
12510
- interested in knowing if a table used for lookup data has changed so
12511
- the application can update a local cache of that table .
12523
+ [Continuous Query Notification (CQN)][99] lets node-oracledb applications
12524
+ subscribe to receive notification when changed data is committed to the
12525
+ database, regardless of the user or the application that made the change. For
12526
+ example your application may be interested in knowing if a table used for lookup
12527
+ data has changed so that the application can update a local cache of that table.
12528
+ CQN can invoke a JavaScript method, which can perform the action .
12512
12529
12513
12530
CQN is suitable for infrequently modified tables. It is recommended
12514
12531
to avoid frequent subscription and unsubscription.
12515
12532
12516
- The connection must be created with [`events`](#propdbevents) mode
12517
- *true*.
12518
-
12519
- The database must be able to connect to the node-oracledb machine for
12520
- notifications to be received. Typically this means that the machine
12521
- running node-oracledb needs a fixed IP address. Note
12522
- `connection.subscribe()` does not verify that this reverse connection
12523
- is possible. If there is any problem sending a notification, then the
12524
- callback method will not be invoked. The configuration options can
12525
- include an [`ipAddress`](#consubscribeoptipaddress) and
12526
- [`port`](#consubscribeoptport) on which to listen for notifications,
12527
- otherwise the database chooses values.
12528
-
12529
- To register interest in database changes, the
12530
- [`connection.subscribe()`](#consubscribe) method is passed an
12531
- arbitrary name and an [`options`](#consubscribeoptions) object that
12532
- controls notification. In particular `options` contains a valid SQL
12533
- query and a JavaScript callback:
12533
+ By default, CQN requires the database to be able to connect back to the
12534
+ node-oracledb application for notifications to be received. This typically
12535
+ means that the machine running node-oracledb needs a fixed IP address. Note
12536
+ `connection.subscribe()` does not verify that this reverse connection is
12537
+ possible. If there is any problem sending a notification, then the callback
12538
+ method will not be invoked. The configuration options can include an
12539
+ [`ipAddress`](#consubscribeoptipaddress) and [`port`](#consubscribeoptport) on
12540
+ which to listen for notifications, otherwise the database chooses values.
12541
+
12542
+ Alternatively, when using Oracle Database and Oracle client libraries 19.4, or
12543
+ later, subscriptions can set the optional
12544
+ [`clientInitiated`](#consubscribeoptclientinitiated) property to *true*. This
12545
+ makes CQN internally use the same approach as normal connections to the
12546
+ database, and does not require the database to be able to connect back to the
12547
+ application. Since client initiated CQN notifications do not need additional
12548
+ network configuration, they have ease-of-use and security advantages.
12549
+
12550
+ To register interest in database changes, the connection must be created with
12551
+ [`events`](#propdbevents) mode *true*. Then the
12552
+ [`connection.subscribe()`](#consubscribe) method is passed an arbitrary name and
12553
+ an [`options`](#consubscribeoptions) object that controls notification. In
12554
+ particular `options` contains a valid SQL query and a JavaScript callback:
12534
12555
12535
12556
```javascript
12536
12557
function myCallback(message) {
0 commit comments