Skip to content

Commit d0759c6

Browse files
committed
Add msgId attribute in the message object passed onto the callback registered during AQ subscription
1 parent ff9f7c8 commit d0759c6

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

doc/src/release_notes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Thin Mode Changes
6969
Thick Mode Changes
7070
++++++++++++++++++
7171

72+
#) Added msgID (message Id) attribute in the message object passed onto the
73+
callback registered during AQ subscription. The msgID attribute passed
74+
with the callback functions can be compared with the msgID attribute
75+
returned by the deq* functions for proper validation of the returned
76+
message objects during message dequeue.
77+
7278
#) Added support to return a message object from the :meth:`queue.enqOne()
7379
<aqQueue.enqOne()>` and :meth:`queue.enqMany() <aqQueue.enqMany()>`
7480
functions. This message object contains a ``msgId`` attribute identifying

lib/connection.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,7 +1240,7 @@ class Connection extends EventEmitter {
12401240
errors.assertArgCount(arguments, 2, 2);
12411241
errors.assertParamValue(typeof name === 'string', 1);
12421242
errors.assertParamValue(nodbUtil.isObject(options), 2);
1243-
options = {...options};
1243+
options = {name: name, ...options};
12441244
errors.assertParamPropUnsignedInt(options, 2, "namespace");
12451245
if (options.namespace === undefined)
12461246
options.namespace = constants.SUBSCR_NAMESPACE_DBCHANGE;
@@ -1273,7 +1273,6 @@ class Connection extends EventEmitter {
12731273
delete outValue.subscription;
12741274
} else {
12751275
subscription = outValue;
1276-
outValue = undefined;
12771276
}
12781277
_subscriptions.set(name, subscription);
12791278
return outValue;

src/njsConnection.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,9 @@ NJS_NAPI_METHOD_IMPL_ASYNC(njsConnection_subscribe, 2, NULL)
21982198
return false;
21992199
NJS_CHECK_NAPI(env, napi_create_reference(env, callback, 1,
22002200
&baton->subscription->jsCallback))
2201+
if (!njsUtils_getNamedPropertyString(env, args[1], "name",
2202+
&baton->name, &baton->nameLength))
2203+
return false;
22012204
}
22022205

22032206
// get options that are used for registering queries

src/njsSubscription.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ static bool njsSubscription_createMessage(napi_env env,
136136
"queries", array))
137137
}
138138

139+
// msgId
140+
if (message->aqMsgId && message->aqMsgIdLength > 0) {
141+
NJS_CHECK_NAPI(env, napi_create_buffer_copy(env,
142+
message->aqMsgIdLength, message->aqMsgId, NULL, &temp))
143+
NJS_CHECK_NAPI(env, napi_set_named_property(env, *messageObj, "msgId",
144+
temp))
145+
}
146+
139147
return true;
140148
}
141149

0 commit comments

Comments
 (0)