Search code examples
oracle-aq

Request-reply with Oracle AQ


I want to implement the request-reply pattern using Oracle AQ. Basically a "requestor" would:

  1. Enqueue a request message.
  2. Take the message ID generated for the request message.
  3. Dequeue the reply message, specifying in the dequeue options the correlation property as being the message ID of the original request message.

It turns out that the in the DBMS_AQ.ENQUEUE procedure, the msgid OUT parameter which returns the original message ID is a RAW, while the correlation property of the dequeue options is a VARCHAR2(128).

What is the correct way to implement that?


Solution

  • Although I was afraid of simply trying to convert a RAW to a VARCHAR2 (after all, if the return of the API is a RAW, for me, this means that the bytes do not necessarily correspond to a String in a particular charset), it seems that it is just a matter of converting the RAW msgId to VARCHAR2 using TO_CHAR. Curiously, it does not work if you try to use UTL_RAW.CAST_TO_VARCHAR.

    I will proceed with this approach, although it does not make me 100% confident.