09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

queue_name => ’AQ_book_orders’,<br />

queue_table => ‘book_order_qtab’);<br />

-- start the queue<br />

dbms_aqadm.start_queue(‘AQ_book_orders’);<br />

END;<br />

/<br />

Converting Messages<br />

The message system link called fqlink, which connects to a third-party messaging<br />

system, should be created by calling dbms_mgwadm.create_msgsystem_link(<br />

). The foreign queue, FQ_book_orders, of the third-party messaging system<br />

should be registered by calling dbms_mgwadm.register_foreign_queue( ).<br />

Propagating Outbound XML Messages: Example<br />

This example sets up propagation to move book order messages from the AQ<br />

queue, AQ_book_orders, to the foreign queue, FQ_book_orders, in the form of<br />

XML documents. Users can use the package DBMS_XMLSCHEMA to generate an XML<br />

schema from the ADT book_order_typ to parse and process the XML messages<br />

at the third-party messaging system side.<br />

The following script defines a function and a transformation to convert an AQ book<br />

order message to an XML document that is stored in an object of the canonical type<br />

sys.mgw_basic_msg_t. Run the script as user mgwuser.<br />

-- create a transformation function<br />

CREATE OR REPLACE FUNCTION fnc_order2basic (book_order IN book_order_typ)<br />

RETURN sys.mgw_basic_msg_t<br />

IS<br />

v_xml XMLType;<br />

v_text varchar(2000); -- assume book orders in XML document<br />

-- are less than 2000 char long.<br />

v_basic sys.mgw_basic_msg_t;<br />

BEGIN<br />

-- create a XMLType object from the book_order<br />

v_xml := XMLType.createXML(book_order, null, null);<br />

-- convert the XMLType object to XML document (text)<br />

v_text := v_xml.getStringVal();<br />

-- store the XML document in a mgw_basic_msg_t obejct<br />

v_basic := sys.mgw_basic_msg_t.construct;<br />

v_basic.text_body := sys.mgw_text_value_t(v_text, null);<br />

Messaging Gateway 18-41

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!