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 />

/* Assign bytes to the OCIRaw pointer :<br />

Memory needs to be allocated explicitly to OCIRaw*: */<br />

if (status=OCIRawAssignBytes(oeh, err, message_txt, 100,<br />

&message))<br />

{<br />

printf(" error in OCIRawAssignBytes %d \n", status);<br />

exit(1);<br />

}<br />

/* Embedded PLSQL call to the AQ enqueue procedure : */<br />

EXEC SQL EXECUTE<br />

DECLARE<br />

message_properties dbms_aq.message_properties_t;<br />

enqueue_options dbms_aq.enqueue_options_t;<br />

msgid RAW(16);<br />

BEGIN<br />

/* Bind the host variable message to the raw payload: */<br />

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

message_properties => message_properties,<br />

enqueue_options => enqueue_options,<br />

payload => :message,<br />

msgid => msgid);<br />

END;<br />

END-EXEC;<br />

/* Commit work: */<br />

EXEC SQL COMMIT;<br />

/* Dequeue */<br />

/* Embedded PLSQL call to the AQ dequeue procedure :*/<br />

EXEC SQL EXECUTE<br />

DECLARE<br />

message_properties dbms_aq.message_properties_t;<br />

dequeue_options dbms_aq.dequeue_options_t;<br />

msgid RAW(16);<br />

BEGIN<br />

/* Return the raw payload into the host variable ’message’:*/<br />

dbms_aq.dequeue(queue_name => ’raw_msg_queue’,<br />

message_properties => message_properties,<br />

dequeue_options => dequeue_options,<br />

payload => :message,<br />

msgid => msgid);<br />

END;<br />

END-EXEC;<br />

/* Commit work: */<br />

EXEC SQL COMMIT;<br />

A-24 <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!