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.

Propagation Features<br />

Note that AQ does not support propagation from Object queues that have BFILE or<br />

REF attributes in the payload.<br />

Scenario<br />

In the BooksOnLine application, the company may wish to send promotional<br />

coupons along with the book orders. These coupons are generated depending on<br />

the content of the order, and other customer preferences. The coupons are images<br />

generated from some multimedia database, and are stored as LOBs.<br />

When the order information is sent to the shipping warehouses, the coupon<br />

contents are also sent to the warehouses. In the following code, order_typ is<br />

enhanced to contain a coupon attribute of LOB type. The code demonstrates how<br />

the LOB contents are inserted into the message that is enqueued into OE_<br />

bookedorders_que when an order is placed. The message payload is first<br />

constructed with an empty LOB. The place holder (LOB locator) information is<br />

obtained from the queue table and is then used in conjunction with the LOB<br />

manipulation routines, such as DBMS_LOB.WRITE(), to fill the LOB contents. The<br />

example has additional examples regarding for enqueue and dequeue of messages<br />

with LOBs as part the payload.<br />

A COMMIT is issued only after the LOB contents are filled in with the appropriate<br />

image data. Propagation automatically takes care of moving the LOB contents along<br />

with the rest of the message contents. The following code also shows a dequeue at<br />

the destination queue for reading the LOB contents from the propagated message.<br />

The LOB contents are read into a buffer that can be sent to a printer for printing the<br />

coupon.<br />

PL/SQL (DBMS_AQADM Package): Example Code<br />

/* Enhance the type order_typ to contain coupon field (lob field): */<br />

CREATE OR REPLACE TYPE order_typ AS OBJECT (<br />

orderno NUMBER,<br />

status VARCHAR2(30),<br />

ordertype VARCHAR2(30),<br />

orderregion VARCHAR2(30),<br />

customer customer_typ,<br />

paymentmethod VARCHAR2(30),<br />

items orderitemlist_vartyp,<br />

total NUMBER,<br />

coupon BLOB);<br />

/<br />

/* lob_loc is a variable of type BLOB,<br />

buffer is a variable of type RAW,<br />

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