Skip to content

Commit 8862ce9

Browse files
committed
Added changes to verify payload type against queue type
1 parent ff27bb9 commit 8862ce9

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
lines changed

doc/src/release_notes.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@ Common Changes
2929
#) Fixed bug that threw empty error message when NaN values were used
3030
in JSON binds.
3131

32-
#) Added support for :attr:`deqOptions.deliveryMode` in
32+
#) Added support for :attr:`deqOptions.deliveryMode` in
3333
:ref:`Advanced Queuing <aq>`.
3434

35+
#) Added error ``NJS-174`` which is thrown if payload type does not match the
36+
queue type in :ref:`Advanced Queuing <aq>`.
37+
3538
Thin Mode Changes
3639
+++++++++++++++++
3740

lib/aqDeqOptions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2023, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

lib/aqQueue.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -87,17 +87,20 @@ class AqQueue {
8787
}
8888
}
8989

90-
// validate payload
90+
// validate payload/queue type compatibility
9191
if (this._isJson) {
9292
message.payload = transformer.transformJsonValue(payload);
93-
} else if (typeof payload === 'string') {
93+
} else if (typeof payload === 'string' || Buffer.isBuffer(payload)) {
9494
message.payload = Buffer.from(payload);
95-
} else if (Buffer.isBuffer(payload)) {
96-
message.payload = payload;
97-
} else {
95+
} else if (this._payloadType == types.DB_TYPE_OBJECT) {
96+
if (!(payload instanceof BaseDbObject))
97+
errors.throwErr(errors.ERR_PAYLOAD_CANNOT_BE_ENQUEUED);
9898
message.payload = payload._impl;
99+
} else {
100+
errors.throwErr(errors.ERR_PAYLOAD_CANNOT_BE_ENQUEUED);
99101
}
100102

103+
101104
// validate options, if applicable
102105
if (message.correlation !== undefined) {
103106
errors.assertParamPropValue(typeof message.correlation === 'string', 1,

lib/errors.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ const ERR_SESSIONLESS_DIFFERING_METHODS = 170;
179179
const ERR_SESSIONLESS_ALREADY_ACTIVE = 171;
180180
const ERR_SESSIONLESS_INACTIVE = 172;
181181
const ERR_INVALID_SERVER_RESPONSE = 173;
182+
const ERR_PAYLOAD_CANNOT_BE_ENQUEUED = 174;
182183

183184
// Oracle Net layer errors start from 500
184185
const ERR_CONNECTION_CLOSED = 500;
@@ -261,6 +262,7 @@ adjustErrorXref.set("ORA-24344", WRN_COMPILATION_CREATE);
261262
adjustErrorXref.set("ORA-26202", ERR_SESSIONLESS_INACTIVE);
262263
adjustErrorXref.set("ORA-26211", ERR_SESSIONLESS_DIFFERING_METHODS);
263264
adjustErrorXref.set("ORA-26216", ERR_SESSIONLESS_ALREADY_ACTIVE);
265+
adjustErrorXref.set("DPI-1071", ERR_PAYLOAD_CANNOT_BE_ENQUEUED);
264266

265267
// define mapping for error messages
266268
const messages = new Map();
@@ -542,6 +544,9 @@ messages.set(ERR_SESSIONLESS_INACTIVE, //NJS-172
542544
'No sessionless transaction is active');
543545
messages.set(ERR_INVALID_SERVER_RESPONSE, //NJS-173
544546
'Invalid server response to connection request');
547+
messages.set(ERR_PAYLOAD_CANNOT_BE_ENQUEUED, // NJS-174
548+
"Payload cannot be enqueued since it does not match the payload type supported by the queue");
549+
545550

546551
// Oracle Net layer errors
547552

@@ -1003,6 +1008,7 @@ module.exports = {
10031008
ERR_SESSIONLESS_ALREADY_ACTIVE,
10041009
ERR_SESSIONLESS_INACTIVE,
10051010
ERR_INVALID_SERVER_RESPONSE,
1011+
ERR_PAYLOAD_CANNOT_BE_ENQUEUED,
10061012
ERR_CONNECTION_CLOSED_CODE: `${ERR_PREFIX}-${ERR_CONNECTION_CLOSED}`,
10071013
ERR_OPERATION_NOT_SUPPORTED_ON_BFILE,
10081014
ERR_OPERATION_ONLY_SUPPORTED_ON_BFILE,

src/njsAqDeqOptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2022, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//

test/aq2.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2024, Oracle and/or its affiliates. */
1+
/* Copyright (c) 2024, 2025, Oracle and/or its affiliates. */
22

33
/******************************************************************************
44
*
@@ -172,10 +172,10 @@ describe('218. aq2.js', function() {
172172
const message = new objClass(addrData);
173173
await queue1.enqOne(message);
174174
},
175-
/DPI-1071/
175+
/NJS-174/
176176
);
177-
// DPI-1071: payload type in message properties must match
178-
// the payload type of the queue
177+
/* NJS-174: Payload cannot be enqueued since it does not match the payload
178+
type supported by the queue */
179179
}); // 218.4
180180

181181
it('218.5 Enqueue a DB object as payload attribute', async () => {

0 commit comments

Comments
 (0)