-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
- What versions are you using?
[email protected]
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
Oracle Instant Client 19_22
process:
platform: win32
node_version : 20.10.0
arch: x64
-
Is it an error or a hang or a crash?
error -
What error(s) or behavior you are seeing?
On calling deq() or deqMany(1) on an empty queue, the function now returns a msg (on 6.3.0 and according to the documentation, it should return undefined)
Then, on calling payload.toString() on the msg, the process returns the following error :
DPI-1002: invalid dpiMsgProps handle
- Include a runnable Node.js script that shows the problem.
import oracledb from 'oracledb';
const dbConfig = {
user: "user",
password: "password",
connectString: "connectString",
externalAuth: false
};
async function deqAll(){
oracledb.initOracleClient(); // enable node-oracledb Thick mode for oracle version < 12
const connection = await oracledb.getConnection(dbConfig);
let event;
do { // Deq until empty
event = await deq(connection);
if (event) {
console.log(event);
}
} while (event);
await connection.close();
}
async function deq(connection) {
let event;
try {
const queue = await connection.getQueue("EVENT_QUEUE");
queue.deqOptions.wait = oracledb.AQ_DEQ_NO_WAIT; // Don't hang on empty queue
const msg = await queue.deqOne();
if(!msg){
console.log("No event to process.");
return; // Queue empty
}
event = parseMessage(msg);
} catch (error) {
await console.error(`Failed to process event : ${error}`);
} finally {
await connection?.commit();
}
return event;
}
function parseMessage(msg) {
const payload = msg.payload.toString(); // <== Will return "DPI-1002: invalid dpiMsgProps handle" when queue is empty
const event = JSON.parse(payload).event;
return event;
}
deqAll();