JMS Text Message on Oracle AQ from Nodejs

550 views Asked by At

I'm trying to enqueue a jms text message on oracle AQ from nodejs.

const enqueue = async () => {
    try {
        await oracle.createPool();
        const connection = await oracle.getConnection();
        const jmsMessageType = "SYS.AQ$_JMS_TEXT_MESSAGE";

        const queue = await connection.getQueue(bv.REQUEST_QUEUE_NAME, {payloadType: jmsMessageType});

        const theRequest = new queue.payloadTypeClass({
            text_length: request.length,
            text_vc: request
        });
        await queue.enqOne(theRequest);
        await connection.commit();
    } catch(e){
        console.error(e);
    }
}

enqueue();

I can see that the message is queued in the AQ's table in oracle, but the consumer breaks when trying to dequeue the message:

oracle.jms.AQjmsException: JMS-120: Dequeue failed
    at oracle.jms.AQjmsError.throwEx(AQjmsError.java:337)
    at oracle.jms.AQjmsConsumer.jdbcDequeueCommon(AQjmsConsumer.java:1995)
    at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:1374)
    at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:1292)
    at oracle.jms.AQjmsConsumer.receiveFromAQ(AQjmsConsumer.java:1270)
    at oracle.jms.AQjmsConsumer.receiveNoWait(AQjmsConsumer.java:1068)
    ...
Caused by: java.lang.NullPointerException
    at oracle.jms.AQjmsTextMessage.readTextMessageContainer(AQjmsTextMessage.java:328)
    at oracle.jms.AQjmsTextMessage.<init>(AQjmsTextMessage.java:161)
    at oracle.jms.AQjmsConsumer.jdbcDequeueCommon(AQjmsConsumer.java:1751)
    ... 19 more

Any ideas on the correct structure of the JMSTextMessage type?

1

There are 1 answers

1
DaafVader On

Basically just had to get the definitions of the types and user UPPER CASE for the property names. Upper case is very important - it just ignores lower case property names.

  • SYS.AQ$_JMS_TEXT_MESSAGE
  • SYS.AQ$_JMS_HEADER
  • SYS.AQ$_JMS_USERPROPARRAY
  • SYS.AQ$_JMS_USERPROPERTY

Look here if you need more: https://docs.oracle.com/cd/B10501_01/appdev.920/a96612/t_jms3.htm

 const theRequest = new queue.payloadTypeClass(
            {
                HEADER: {
                    USERID: "YOUR_USER",
                    PROPERTIES: [
                        {
                            NAME: "JMS_OracleDeliveryMode",
                            TYPE: 100,
                            STR_VALUE: "2",
                            NUM_VALUE: null,
                            JAVA_TYPE: 27
                        },
                        {
                            NAME: "JMS_OracleTimestamp",
                            TYPE: 200,
                            STR_VALUE: null,
                            NUM_VALUE: new Date().getTime(),
                            JAVA_TYPE: 24
                        }
                    ]
                },
                TEXT_LEN: request.length,
                TEXT_VC: request
            }
        );