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.

Listening to One or More Multiconsumer Queues<br />

Examples<br />

See Chapter 3, "AQ Programmatic Environments" for a list of available functions in<br />

each programmatic environment. Examples in the following programmatic<br />

environments are provided:<br />

PL/SQL (DBMS_AQ Package): Listen to Queues on page 11-37<br />

C (OCI): Listen to Multiconsumer Queues on page 11-38<br />

PL/SQL(DBMS_AQPackage):ListentoQueues<br />

/* The listen call allows you to monitor a list of queues for messages for<br />

specific agents. You need to have dequeue privileges for all the queues<br />

you wish to monitor. */<br />

Listen to Multiconsumer Queue (Timeout of Zero).<br />

DECLARE<br />

Agent_w_msg aq$_agent;<br />

My_agent_list dbms_aq.agent_list_t;<br />

BEGIN<br />

/* NOTE: MCQ1, MCQ2, MCQ3 are multiconsumer queues in SCOTT’s schema<br />

* SCQ1, SCQ2, SCQ3 are single-consumer queues in SCOTT’s schema<br />

*/<br />

Qlist(1):= aq$_agent('agent1', 'MCQ1', NULL);<br />

Qlist(2):= aq$_agent('agent2', 'scott.MCQ2', NULL);<br />

Qlist(3):= aq$_agent('agent3', 'scott.MCQ3', NULL);<br />

/* Listen with a time-out of zero: */<br />

DBMS_AQ.LISTEN(<br />

agent_list => My_agent_list,<br />

wait => 0,<br />

agent => agent_w_msg);<br />

DBMS_OUTPUT.PUT_LINE('Message in Queue :- ' || agent_w_msg.address);<br />

DBMS_OUTPUT.PUT_LINE('');<br />

END;<br />

/<br />

Listen to Mixture of Multiconsumer Queues (Timeout 100 Seconds).<br />

DECLARE<br />

Agent_w_msg aq$_agent;<br />

My_agent_list dbms_aq.agent_list_t;<br />

BEGIN<br />

Operational Interface: Basic Operations 11-37

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

Saved successfully!

Ooh no, something went wrong!