Dequeue Oracle Advance Queue using NodeJs

const oracledb = require('oracledb');
const dbConfig = require('./dbconfig.js');

const queueName = "QUEUENAME";
async function deq() {
    let connection;
    try {
        connection = await oracledb.getConnection(dbConfig);
        const queue = await connection.getQueue(queueName, { payloadType: "SYS.AQ$_JMS_TEXT_MESSAGE" });
        Object.assign(
            queue.deqOptions,
            {
              visibility: oracledb.AQ_VISIBILITY_IMMEDIATE, 
              wait: 5 ,
              consumerName: "FLIGHT_KEY_ORACLE_SUBSCRIBER"  
            }
          );
        const msg = await queue.deqOne();
        if (msg) {
            console.log('Dequeued:  ' + JSON.stringify(msg, null, 4));
        } else {
            console.log('No message to dequeue');
        }

    } catch (err) {
        console.error("Error>>"+err);
    } finally {
        if (connection) {
            try {
                deq();
                //await connection.close();
            } catch (err) {
                console.error(err);
            }
        }
    }
}
deq();