Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdpii\tdpii_messaging012.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <title>Task 4: Configuring a Messaging Client to Dequeue Messages</title> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-06-04T17:1:2Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Task 4: Configuring a Messaging Client to Dequeue Messages" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10703-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdpii_messaging011.htm" title="Previous" type="text/html" /> <link rel="next" href="tdpii_messaging013.htm" title="Next" type="text/html" /> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdpii_messaging011.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging013.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="CHDHGJAG" name="CHDHGJAG"></a><a id="TDPII039" name="TDPII039"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>Task 4: Configuring a Messaging Client to Dequeue Messages<a id="sthref605" name="sthref605"></a><a id="sthref606" name="sthref606"></a><a id="sthref607" name="sthref607"></a><a id="sthref608" name="sthref608"></a><a id="sthref609" name="sthref609"></a></h1> <a name="BEGIN" id="BEGIN"></a> <p>Configure a mechanism to dequeue the messages in your messaging system. Typically, an application dequeues and processes messages that were created by another application. For simplicity, this example creates a PL/SQL procedure called <code>dequeue_orders</code> to dequeue messages that include the order ID and order date of an order. You call the procedure to dequeue messages in this example, but an application can run such a procedure periodically.</p> <p class="orderedlisttitle">To configure a messaging client to dequeue messages: </p> <ol> <li> <p>Grant <code>EXECUTE</code> privilege on the <code>SYS.DBMS_STREAMS_MESSAGING</code> package to the Oracle Streams administrator at the <code>ii2.example.com</code> database. See Step <a href="tdpii_messaging011.htm#BABFAHIF">1</a> in <a href="tdpii_messaging011.htm#CHDBIECC">"Task 3: Configuring a Message Enqueuing Mechanism"</a> for an example that grants this privilege to the Oracle Streams administrator in the <code>ii1.example.com</code> database.</p> </li> <li> <p>On a command line, open SQL*Plus and connect to the <code>ii2.example.com</code> database as the Oracle Streams administrator.</p> <p>See <a href="topicid:ADMQS0361">Starting SQL*Plus and Connecting to the Database</a> for more information about starting SQL*Plus.</p> </li> <li> <p><a id="sthref611" name="sthref611"></a>Create a messaging client to enable the Oracle Streams administrator to dequeue messages from the <code>streams_queue</code> queue:</p> <pre xml:space="preserve" class="oac_no_warn"> BEGIN DBMS_STREAMS_ADM.ADD_MESSAGE_RULE ( message_type => 'strmadmin.order_id_date', rule_condition => ':MSG.ORDER_ID > 0', streams_type => 'DEQUEUE', streams_name => 'strmadmin', queue_name => 'strmadmin.streams_queue'); END; / </pre> <p>The user name of the Oracle Streams administrator must be specified for the <code>streams_name</code> parameter. In this example, the user name of the Oracle Streams administrator is <code>strmadmin</code>.</p> <p>A messaging client uses rules to determine which messages to dequeue. In this example, the rule for the messaging client specifies that all messages with an <code>order_id</code> greater than zero should be dequeued. So, with this rule, the messaging client will dequeue all new messages of type <code>strmadmin.order_id_date</code> that appear in the <code>strmadmin.streams_queue</code> queue.</p> </li> <li> <p>In Oracle Enterprise Manager, log in to the <code>ii2.example.com</code> database as the Oracle Streams administrator.</p> </li> <li> <p>Go to the Database Home page.</p> </li> <li> <p>Click <span class="bold">Schema</span> to open the Schema subpage.</p> </li> <li> <p>Click <span class="bold">Procedures</span> in the Programs section.</p> </li> <li> <p>On the Procedures page, click <img src="shortcut.png" alt="callback" border="0" /><a href="javascript:void(0);" onclick="redirectEMpage('PROCEDURE_CREATE');"><span class="bold">Create</span></a>.</p> </li> <li> <p>On the Create Procedure page, enter <code>dequeue_orders</code> in the Name field.</p> </li> <li> <p>Ensure that <code>strmadmin</code> is entered in the Schema field.</p> </li> <li> <p>Delete the sample text in the Source field.</p> </li> <li> <p><a id="sthref612" name="sthref612"></a>Enter the following in the Source field:</p> <pre xml:space="preserve" class="oac_no_warn"> AS msg ANYDATA; user_msg strmadmin.order_id_date; num_var PLS_INTEGER; more_messages BOOLEAN := TRUE; navigation VARCHAR2(30); BEGIN navigation := 'FIRST MESSAGE'; WHILE (more_messages) LOOP BEGIN DBMS_STREAMS_MESSAGING.DEQUEUE( queue_name => 'strmadmin.streams_queue', streams_name => 'strmadmin', payload => msg, navigation => navigation, wait => DBMS_STREAMS_MESSAGING.NO_WAIT); IF msg.GETTYPENAME() = 'STRMADMIN.ORDER_ID_DATE' THEN num_var := msg.GETOBJECT(user_msg); DBMS_OUTPUT.PUT_LINE('Order ID: ' || user_msg.order_id); DBMS_OUTPUT.PUT_LINE('Order Date: ' || user_msg.order_date); END IF; navigation := 'NEXT MESSAGE'; COMMIT; EXCEPTION WHEN SYS.DBMS_STREAMS_MESSAGING.ENDOFCURTRANS THEN navigation := 'NEXT TRANSACTION'; WHEN DBMS_STREAMS_MESSAGING.NOMOREMSGS THEN more_messages := FALSE; DBMS_OUTPUT.PUT_LINE('No more messages.'); WHEN OTHERS THEN RAISE; END; END LOOP; END; </pre></li> <li> <p>Click <span class="bold">OK</span>.</p> </li> <li> <p>Complete the steps in <a href="tdpii_messaging013.htm#CHDBIDGD">"Task 5: Enqueuing Messages"</a> to continue this extended example.</p> </li> </ol> <div class="helpinfonote"> <p><span class="bold">Note: </span>You can also use the <a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=SQLRF01309','newWindow').focus()"><code>CREATE</code> <code>PROCEDURE</code></a> SQL statement to create a procedure.</p> </div> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdpii_messaging008.htm#CHDBACBE">Tutorial: Sending Messages Between Oracle Databases</a></p> <p><a href="tdpii_messaging001.htm#CHDIJFHB">About Messaging</a></p> </div> </div> <!-- class="sect2" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 2007, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdpii_messaging011.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging013.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de