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.

Dequeue Features<br />

}<br />

Listen Capability<br />

"(tab.user_data.ordertype = 'RUSH' AND " +<br />

"tab.user_data.customer.country = 'USA')";<br />

bookedorders_q.addSubscriber(agt2, rule);<br />

/* Add a rule-based subscriber for Overseas Shipping<br />

Intl Shipping handles all non-U.S. orders: */<br />

agt3 = new AQAgent("Overseas_Shipping", "OS.OS_bookedorders_que");<br />

rule = "tab.user_data.orderregion = 'INTERNATIONAL'";<br />

bookedorders_q.addSubscriber(agt3, rule);<br />

}<br />

catch (Exception ex)<br />

{<br />

System.out.println("Exception: " + ex);<br />

}<br />

<strong>Advanced</strong> <strong>Queuing</strong> can monitor multiple queues for messages with a single call,<br />

LISTEN. An application can use LISTEN to wait for messages for multiple<br />

subscriptions. It can also be used by gateway applications to monitor multiple<br />

queues. If the LISTEN call returns successfully, a dequeue must be used to retrieve<br />

the message (see "Listening to One or More Single-Consumer Queues" on<br />

page 11-23.<br />

Without the LISTEN call, an application which sought to dequeue from a set of<br />

queues would have to continuously poll the queues to determine if there were a<br />

message. Alternatively, you could design your application to have a separate<br />

dequeue process for each queue. However, if there are long periods with no traffic<br />

in any of the queues, these approaches will create unacceptable overhead. The<br />

LISTEN call is well suited for such applications.<br />

Note that when there are messages for multiple agents in the agent list, LISTEN<br />

returns with the first agent for whom there is a message. In that sense LISTEN is not<br />

'fair' in monitoring the queues. The application designer must keep this in mind<br />

when using the call. To prevent one agent from 'starving' other agents for messages,<br />

the application can change the order of the agents in the agent list.<br />

8-90 <strong>Oracle</strong>9i Application Developer’s Guide - <strong>Advanced</strong> <strong>Queuing</strong>

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

Saved successfully!

Ooh no, something went wrong!