09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Converting Messages<br />

Propagating Inbound XML Messages: Example<br />

This example sets up propagation to move book orders, which are XML documents<br />

conforming to the XML schema associated with the PL/SQL type book_order_<br />

typ, from the foreign queue, FQ_book_orders, to the AQ queue, AQ_book_<br />

orders. Users should use the package DBMS_XMLSCHEMA to generate XML schema<br />

from the ADT book_order_typ to generate valid XML book order messages.<br />

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

order in the form of an XML document stored in an object of the canonical type<br />

sys.mgw_basic_msg_t to an object of ADT book_order_typ. Run the script as<br />

mgwuser.<br />

-- create a transformation function<br />

CREATE OR REPLACE FUNCTION fnc_basic2order(basic IN sys.mgw_basic_msg_t)<br />

RETURN book_order_typ<br />

IS<br />

v_xml XMLType;<br />

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

-- are less than 2000 char<br />

long<br />

v_order book_order_typ;<br />

BEGIN<br />

v_text := basic.text_body.small_value;<br />

/<br />

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

v_xml.toObject(v_order);<br />

return v_order;<br />

END fnc_basic2order;<br />

-- grant execute privilege to PUBLIC in order for the agent to be able to call<br />

it<br />

GRANT EXECUTE on fnc_basic2order to PUBLIC;<br />

-- create a transformation with the function<br />

BEGIN<br />

dbms_transform.create_transformation(<br />

schema => ‘mgwuser’,<br />

name => ‘basic2order’,<br />

from_schema => ‘sys’,<br />

from_type => ‘mgw_basic_msg_t’,<br />

to_schema => ‘mgwuser’,<br />

Messaging Gateway 18-43

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

Saved successfully!

Ooh no, something went wrong!