Tuesday, March 7, 2017

create and post message to AQ with XMLTYPE as the payload type.

This post shows how to create an AQ with XMLTYPE as the payload type.
This is useful when the payload structure is not known or DB guys do not want to define objects and just go with XMLTYPE.
It can accept any xml request, which can then be consumed and transformed accordingly in SOA for further use.

I assume you already have privileges to create AQ. (If not then refer this post to grant privileges.)


--Queue Table
BEGIN
 DBMS_AQADM.CREATE_QUEUE_TABLE( Queue_table => 'QT_SampleQueue', Queue_payload_type => 'SYS.XMLTYPE', Sort_list => 'ENQ_TIME', COMMENT => 'A sample queue table');
END;

--Queue
BEGIN
DBMS_AQADM.CREATE_QUEUE (
queue_name =>'SampleQueue',
queue_table=>'QT_SampleQueue');
END;


SELECT queue_table,type,object_type,recipients FROM USER_QUEUE_TABLES;


exec DBMS_AQADM.START_QUEUE('SampleQueue');




--Post request
DECLARE
 
  queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
  message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
  message_id RAW(16);
  message SYS.XMLType;
 
BEGIN
 
  message := sys.XMLType.createXML('<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description> 
</book></catalog>');

  DBMS_AQ.ENQUEUE( queue_name => 'SampleQueue',
                   enqueue_options => queue_options,
                   message_properties => message_properties,
                   payload => message,
                   msgid => message_id);
  COMMIT;
END;

2 comments:

  1. KING CASINO, LLC GIVES A $100 FREE BET
    KING CASINO, LLC GIVES A $100 FREE BET https://deccasino.com/review/merit-casino/ to try. Visit us today and receive a $100 herzamanindir.com/ FREE poormansguidetocasinogambling BET! 토토 사이트 Sign up at our new site!

    ReplyDelete