09.12.2012 Views

Advanced Queuing - Oracle

Advanced Queuing - Oracle

Advanced Queuing - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

SELECT t.user_data.data INTO lob_loc<br />

FROM qt1 t<br />

WHERE t.msgid = enq_msgid;<br />

DBMS_LOB.WRITE(lob_loc, 2000, 1, buffer );<br />

COMMIT;<br />

END;<br />

/* Dequeue lob data: */<br />

CREATE OR REPLACE PROCEDURE blobdequeue AS<br />

dequeue_options DBMS_AQ.dequeue_options_t;<br />

message_properties DBMS_AQ.message_properties_t;<br />

mid RAW(16);<br />

pload aq.message;<br />

lob_loc BLOB;<br />

amount BINARY_INTEGER;<br />

buffer RAW(4096);<br />

Enqueuing and Dequeuing Of Messages<br />

BEGIN<br />

DBMS_AQ.DEQUEUE(’aq.queue1’, dequeue_options, message_properties,<br />

pload, mid);<br />

lob_loc := pload.data;<br />

-- read the lob data info buffer<br />

amount := 2000;<br />

DBMS_LOB.READ(lob_loc, amount, 1, buffer);<br />

DBMS_OUTPUT.PUT_LINE(’Amount of data read: ’||amount);<br />

COMMIT;<br />

END;<br />

/* Do the enqueues and dequeues: */<br />

SET SERVEROUTPUT ON<br />

BEGIN<br />

FOR i IN 1..5 LOOP<br />

blobenqueue(i);<br />

END LOOP;<br />

END;<br />

BEGIN<br />

FOR i IN 1..5 LOOP<br />

blobdequeue();<br />

END LOOP;<br />

END;<br />

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

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

Saved successfully!

Ooh no, something went wrong!