CREATE OR REPLACE PROCEDURE "&1".CUSTOMER_I_EVENT_CALLBACK(CONTEXT  RAW,
                                                      REGINFO  SYS.AQ$_REG_INFO,
                                                      DESCR    SYS.AQ$_DESCRIPTOR,
                                                      PAYLOAD  RAW,
                                                      PAYLOADL NUMBER) IS
  --version 0.1													  
  L_DEQUEUE_OPTIONS    DBMS_AQ.DEQUEUE_OPTIONS_T;
  L_MESSAGE_PROPERTIES DBMS_AQ.MESSAGE_PROPERTIES_T;
  L_MESSAGE_HANDLE     RAW(16);
  L_PAYLOAD            SYS.AQ$_JMS_TEXT_MESSAGE;
  MESSAGE_CLOB         CLOB;
  SOLACE_TOPIC         VARCHAR2(500);

BEGIN

  L_DEQUEUE_OPTIONS.MSGID := DESCR.MSG_ID;
  L_DEQUEUE_OPTIONS.WAIT  := DBMS_AQ.NO_WAIT;
  L_DEQUEUE_OPTIONS.NAVIGATION := DBMS_AQ.FIRST_MESSAGE;

  DBMS_AQ.DEQUEUE(QUEUE_NAME         => DESCR.QUEUE_NAME,
                  DEQUEUE_OPTIONS    => L_DEQUEUE_OPTIONS,
                  MESSAGE_PROPERTIES => L_MESSAGE_PROPERTIES,
                  PAYLOAD            => L_PAYLOAD,
                  MSGID              => L_MESSAGE_HANDLE);

  SOLACE_TOPIC := L_PAYLOAD.GET_STRING_PROPERTY('solace_topic');
  DBMS_LOB.CREATETEMPORARY(MESSAGE_CLOB, TRUE);
  IF L_PAYLOAD.TEXT_LOB IS NOT NULL THEN
     DBMS_LOB.COPY(MESSAGE_CLOB,
                L_PAYLOAD.TEXT_LOB,
                DBMS_LOB.GETLENGTH(L_PAYLOAD.TEXT_LOB));
  ELSE   
      DBMS_LOB.WRITEAPPEND(MESSAGE_CLOB, LENGTH(L_PAYLOAD.TEXT_VC), L_PAYLOAD.TEXT_VC);  
  END IF; 
  "&1".PROCESS_MESSAGE_FROM_SOLACE(MESSAGE_CLOB,
                              SOLACE_TOPIC);
  DBMS_LOB.FREETEMPORARY(MESSAGE_CLOB);
END CUSTOMER_I_EVENT_CALLBACK;
/
exit;
