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.

General Features of <strong>Advanced</strong> <strong>Queuing</strong><br />

queue in the database. This simplifies the administrative work because all<br />

administrative scripts for the queues in a database can be managed under one<br />

schema. For more information, see "<strong>Oracle</strong> Enterprise Manager Support" on<br />

page 4-8.<br />

PL/SQL (DBMS_AQADM Package): Scenario and Code<br />

In the BooksOnLine application, the DBA creates BOLADM, the BooksOnLine<br />

Administrator account, as the queue administrator of the database. This allows<br />

BOLADM to create, drop, manage, and monitor queues in the database. If PL/SQL<br />

packages are needed in the BOLADM schema for applications to enqueue and<br />

dequeue, the DBA should grant ENQUEUE_ANY and DEQUEUE_ANY system<br />

privileges to BOLADM:<br />

CREATE USER BOLADM IDENTIFIED BY BOLADM;<br />

GRANT CONNECT, RESOURCE, aq_administrator_role TO BOLADM;<br />

GRANT EXECUTE ON dbms_aq TO BOLADM;<br />

GRANT EXECUTE ON dbms_aqadm TO BOLADM;<br />

EXECUTE dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','BOLADM',FALSE);<br />

EXECUTE dbms_aqadm.grant_system_privilege('DEQUEUE_ANY','BOLADM',FALSE);<br />

If using the Java AQ API, BOLADM must be granted execute privileges on the<br />

DBMS_AQIN package:<br />

GRANT EXECUTE ON DBMS_AQIN to BOLADM;<br />

In the application, AQ propagators populate messages from the Order Entry(OE)<br />

schema to the Western Sales (WS), Eastern Sales (ES) and Worldwide Sales (OS)<br />

schemas. The WS, ES and OS schemas in turn populate messages to the Customer<br />

Billing (CB) and Customer Service (CS) schemas. Hence the OE, WS, ES and OS<br />

schemas all host queues that serve as the source queues for the propagators.<br />

When messages arrive at the destination queues, sessions based on the source<br />

queue schema name are used for enqueuing the newly arrived messages into the<br />

destination queues. This means that you need to grant schemas of the source<br />

queues enqueue privileges to the destination queues.<br />

To simplify administration, all schemas that host a source queue in the<br />

BoooksOnLine application are granted the ENQUEUE_ANY system privilege:<br />

EXECUTE dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','OE',FALSE);<br />

EXECUTE dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','WS',FALSE);<br />

EXECUTE dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','ES',FALSE);<br />

EXECUTE dbms_aqadm.grant_system_privilege('ENQUEUE_ANY','OS',FALSE);<br />

A Sample Application Using AQ 8-3

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

Saved successfully!

Ooh no, something went wrong!