Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdpii\tdpii_messaging011.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 3: Configuring a Message Enqueuing Mechanism</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 3: Configuring a Message Enqueuing Mechanism" /> <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_messaging010.htm" title="Previous" type="text/html" /> <link rel="next" href="tdpii_messaging012.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_messaging010.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging012.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="CHDBIECC" name="CHDBIECC"></a><a id="TDPII038" name="TDPII038"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>Task 3: Configuring a Message Enqueuing Mechanism<a id="sthref598" name="sthref598"></a><a id="sthref599" name="sthref599"></a><a id="sthref600" name="sthref600"></a></h1> <a name="BEGIN" id="BEGIN"></a> <p>Configure a mechanism to enqueue the messages in your messaging system. Typically, an application creates and enqueues messages that will be dequeued and processed by another application. For simplicity, this example creates a trigger called <code>enqueue_orders</code> to enqueue a message that includes the order ID and order date of an order. The trigger fires when an order is inserted into the <code>oe.orders</code> table.</p> <p class="orderedlisttitle">To configure a message enqueuing mechanism: </p> <ol> <li><a id="BABFAHIF" name="BABFAHIF"></a> <p>Grant the <code>EXECUTE</code> privilege on the <code>DBMS_STREAMS_MESSAGING</code> package to the Oracle Streams administrator.</p> <p>This example configures a trigger that runs the <code>ENQUEUE</code> procedure in the <code>DBMS_STREAMS_MESSAGING</code> package. The user who runs this procedure in a trigger must have explicit <code>EXECUTE</code> privilege on the package that contains the procedure. The privilege cannot be granted through a role. Therefore, the Oracle Streams administrator must be granted explicit <code>EXECUTE</code> privilege on the package.</p> <ol> <li> <p><a id="sthref602" name="sthref602"></a>Log in to Enterprise Manager as an administrative user who can grant privileges to the <code>strmadmin</code> user. For example, you can log in as a user with <code>SYSDBA</code> privilege. In this example, log in to the <code>ii1.example.com</code> database.</p> </li> <li> <p>Go to the Database Home page.</p> </li> <li> <p>Click <span class="bold">Server</span> to open the Server subpage.</p> </li> <li> <p>Click <img src="shortcut.png" alt="callback" border="0" /><a href="javascript:void(0);" onclick="redirectEMpage('USER_MAIN');"><span class="bold">Users</span></a> in the Security section.</p> <p>The Users page appears.</p> </li> <li> <p>Select the <code>STRMADMIN</code> user.</p> </li> <li> <p>Click <span class="bold">Edit</span>.</p> <p>The Edit User page appears, showing the General subpage.</p> </li> <li> <p>Click <span class="bold">Object Privileges</span> to open the Object Privileges subpage.</p> </li> <li> <p>Select <span class="bold">Package</span> in the Select Object Type list.</p> </li> <li> <p>Click <span class="bold">Add</span> to open the Add Package Object Privileges page.</p> </li> <li> <p>Enter <code>SYS.DBMS_STREAMS_MESSAGING</code> in the Select Package Objects field.</p> </li> <li> <p>Move <span class="bold">EXECUTE</span> from the Available Privileges list to the Selected Privileges list.</p> </li> <li> <p>Click <span class="bold">OK</span> to add the privilege.</p> </li> <li> <p>Click <span class="bold">Apply</span> to grant the privilege.</p> </li> <li> <p>Log out of Enterprise Manager.</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=SQLRF01603','newWindow').focus()"><code>GRANT</code></a> SQL statement to grant privileges to a user.</p> </div> </li> <li> <p><a id="sthref603" name="sthref603"></a>Create a trigger in the <code>ii1.example.com</code> database to enqueue a message automatically when a change is made to the <code>oe.orders</code> table.</p> <ol> <li> <p>Log in to <code>ii1.example.com</code> database in Enterprise Manager 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">Triggers</span> in the Programs section.</p> </li> <li> <p>On the Triggers page, click <img src="shortcut.png" alt="callback" border="0" /><a href="javascript:void(0);" onclick="redirectEMpage('TRIGGER_CREATE');"><span class="bold">Create</span></a>.</p> <p>The Create Trigger page appears, showing the General subpage.</p> </li> <li> <p>Enter <code>enqueue_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><a id="sthref604" name="sthref604"></a>Enter the following in the Trigger Body field:</p> <pre xml:space="preserve" class="oac_no_warn"> DECLARE message strmadmin.order_id_date; BEGIN message := strmadmin.order_id_date( order_id => :NEW.order_id, order_date => TO_CHAR(:NEW.order_date)); DBMS_STREAMS_MESSAGING.ENQUEUE ( queue_name => 'strmadmin.streams_queue', payload => ANYDATA.CONVERTOBJECT(message)); END; </pre></li> <li> <p>Click <span class="bold">Event</span> to open the Event subpage.</p> </li> <li> <p>Ensure that <span class="bold">Table</span> is selected in the Trigger On list.</p> </li> <li> <p>Enter <code>oe.orders</code> in the Table (Schema.Table) field.</p> </li> <li> <p>Select <span class="bold">After</span> for <span class="bold">Fire Trigger</span>.</p> </li> <li> <p>Select <span class="bold">Insert</span> for Event. In this example, only Insert should be selected because the messages track new orders, not changes to existing orders.</p> </li> <li> <p>Click <span class="bold">Advanced</span>.</p> </li> <li> <p>Select <span class="bold">Trigger for each row</span>.</p> </li> <li> <p>Enter <code>OLD</code> in the Old as field in the Referencing section.</p> </li> <li> <p>Enter <code>NEW</code> in the New as field in the Referencing section.</p> </li> <li> <p>Click <span class="bold">OK</span> to create the trigger.</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=SQLRF01405','newWindow').focus()"><code>CREATE</code> <code>TRIGGER</code></a> SQL statement to create a trigger.</p> </div> </li> <li> <p>Complete the steps in <a href="tdpii_messaging012.htm#CHDHGJAG">"Task 4: Configuring a Messaging Client to Dequeue Messages"</a> to continue this extended example.</p> </li> </ol> <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_messaging010.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging012.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