Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdpii\tdpii_messaging018.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 Mechanism for Dequeuing 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:3Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Task 3: Configuring a Mechanism for Dequeuing 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_messaging017.htm" title="Previous" type="text/html" /> <link rel="next" href="tdpii_messaging019.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_messaging017.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging019.htm"><img src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="BABFGHCC" name="BABFGHCC"></a><a id="TDPII099" name="TDPII099"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>Task 3: Configuring a Mechanism for Dequeuing Messages<a id="sthref632" name="sthref632"></a><a id="sthref633" name="sthref633"></a></h1> <a name="BEGIN" id="BEGIN"></a> <p>In this extended example, the second application must be able to dequeue messages from the <code>streams_queue</code> queue. For simplicity, this example creates a PL/SQL procedure called <code>dequeue_app_messages</code> to dequeue messages of type <code>strmadmin.app_info</code>. This procedure uses the messaging client created in <a href="tdpii_messaging017.htm#BABGHHDA">"Task 2: Configuring a Queue and a Messaging Client"</a> to dequeue messages.</p> <p class="orderedlisttitle">To configure a mechanism for dequeuing messages: </p> <ol> <li> <p>Grant the <code>EXECUTE</code> privilege on the <code>DBMS_AQ</code> package to the Oracle Streams administrator.</p> <p>This example configures a procedure that runs the <code>DEQUEUE</code> procedure in the <code>DBMS_AQ</code> package. The user who runs this procedure 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="sthref635" name="sthref635"></a>Log in to Enterprise Manager as an administrative user who can grant privileges to the <code>strmadmin</code> user.</p> </li> <li> <p>Go to 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 General subpage of the Edit User page appears.</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_AQ</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> </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>Create a PL/SQL procedure that dequeues messages.</p> <ol> <li> <p>In Oracle Enterprise Manager, log in to the 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_app_messages</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="sthref636" name="sthref636"></a>Enter the following in the Source field:</p> <pre xml:space="preserve" class="oac_no_warn"> ( context ANYDATA, reginfo SYS.AQ$_REG_INFO, descr SYS.AQ$_DESCRIPTOR) AS dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T; message_properties DBMS_AQ.MESSAGE_PROPERTIES_T; message_handle RAW(16); message ANYDATA; app_message strmadmin.app_info; rc PLS_INTEGER; BEGIN -- Get the message identifier and consumer name from the descriptor dequeue_options.msgid := descr.msg_id; dequeue_options.consumer_name := descr.consumer_name; -- Dequeue the message DBMS_AQ.DEQUEUE( queue_name => descr.queue_name, dequeue_options => dequeue_options, message_properties => message_properties, payload => message, msgid => message_handle); rc := message.getobject(app_message); COMMIT; END; </pre> <p>A message notification PL/SQL procedure must have the following signature:</p> <pre xml:space="preserve" class="oac_no_warn"> PROCEDURE <span class="italic">procedure_name</span>( context IN ANYDATA, reginfo IN SYS.AQ$_REG_INFO, descr IN SYS.AQ$_DESCRIPTOR); </pre> <p>Here, <code><span class="codeinlineitalic">procedure_name</span></code> stands for the name of the procedure. The procedure is a <code>PLSQLCALLBACK</code> data structure that specifies the user-defined PL/SQL procedure to be invoked on message notification.</p> <p>The procedure in this example is a simple notification procedure that dequeues a message of type <code>strmadmin.app_info</code> type using the message identifier and consumer name sent by the notification.</p> </li> <li> <p>Click <span class="bold">OK</span> to create the procedure.</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> </li> <li> <p>Complete the steps in <a href="tdpii_messaging019.htm#BABJIDFE">"Task 4: Configuring Message Notification"</a> to continue this extended example.</p> </li> </ol> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdpii_messaging015.htm#CHDGEHCF">Tutorial: Configuring Message Notifications</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_messaging017.htm"><img src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdpii_messaging019.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