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.

Dequeue Features<br />

><br />

/* processes the next order available in the booked_order_queue */<br />

CREATE OR REPLACE PROCEDURE process_next_order()<br />

AS<br />

dqqopt dbms_aq.dequeue_options_t;<br />

msgprop dbms_aq.message_properties_t;<br />

deq_msgid RAW(16);<br />

book BOLADM.book_typ;<br />

item BOLADM.orderitem_typ;<br />

BOLADM.order_typ order;<br />

BEGIN<br />

><br />

dqqopt.dequeue_option := DBMS_AQ.FIRST_MESSAGE;<br />

dbms_aq.dequeue('WS.WS_BOOKED_ORDERS_QUEUE', dqqopt, msgprop, order,<br />

deq_msgid<br />

);<br />

><br />

/* for simplicity, assume order has a single item */<br />

item = order.items(1);<br />

book = the_orders.item;<br />

><br />

/* assume search_inventory searches inventory for the book */<br />

/* if we don't find the book in the warehouse, abort transaction */<br />

IF (search_inventory(book) != TRUE)<br />

rollback;<br />

ELSE<br />

process_order(order);<br />

END IF;<br />

><br />

END;<br />

/<br />

Visual Basic (OO4O): Example Code<br />

Use the dbexecutesql interface from the database for this functionality.<br />

Java (JDBC): Example Code<br />

public static void setup_queue(Connection db_conn)<br />

{<br />

AQSession aq_sess;<br />

AQQueue bookedorders_q;<br />

AQQueueProperty q_prop;<br />

try<br />

{<br />

8-78 <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!