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.

Enqueuing and Dequeuing Of Messages<br />

Enqueuing and Dequeuing of Messages with Time Delay and Expiration Using<br />

PL/SQL<br />

/* Enqueue message for delayed availability: */<br />

DECLARE<br />

enqueue_options dbms_aq.enqueue_options_t;<br />

message_properties dbms_aq.message_properties_t;<br />

message_handle RAW(16);<br />

message aq.Message_typ;<br />

BEGIN<br />

message := Message_typ(’DELAYED’,<br />

’This message is delayed one week.’);<br />

message_properties.delay := 7*24*60*60;<br />

message_properties.expiration := 2*7*24*60*60;<br />

dbms_aq.enqueue(queue_name => ’msg_queue’,<br />

enqueue_options => enqueue_options,<br />

message_properties => message_properties,<br />

payload => message,<br />

msgid => message_handle);<br />

END;<br />

Note: Expiration is calculated from the earliest dequeue time. So,<br />

if an application wants a message to be dequeued no earlier than a<br />

week from now, but no later than 3 weeks from now, this requires<br />

setting the expiration time for 2 weeks. This scenario is described in<br />

the following code segment.<br />

COMMIT;<br />

<strong>Oracle</strong> <strong>Advanced</strong> <strong>Queuing</strong> by Example A-37

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

Saved successfully!

Ooh no, something went wrong!