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.

sb4 errcode = 0;<br />

Asynchronous Notifications<br />

switch (status)<br />

{<br />

case OCI_SUCCESS:<br />

break;<br />

case OCI_SUCCESS_WITH_INFO:<br />

(void) printf("Error - OCI_SUCCESS_WITH_INFO\n");<br />

break;<br />

case OCI_NEED_DATA:<br />

(void) printf("Error - OCI_NEED_DATA\n");<br />

break;<br />

case OCI_NO_DATA:<br />

(void) printf("Error - OCI_NODATA\n");<br />

break;<br />

case OCI_ERROR:<br />

(void) OCIErrorGet((dvoid *)errhp, (ub4) 1, (text *) NULL, &errcode,<br />

errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);<br />

(void) printf("Error - %.*s\n", 512, errbuf);<br />

break;<br />

case OCI_INVALID_HANDLE:<br />

(void) printf("Error - OCI_INVALID_HANDLE\n");<br />

break;<br />

case OCI_STILL_EXECUTING:<br />

(void) printf("Error - OCI_STILL_EXECUTE\n");<br />

break;<br />

case OCI_CONTINUE:<br />

(void) printf("Error - OCI_CONTINUE\n");<br />

break;<br />

default:<br />

break;<br />

}<br />

}<br />

PL/SQL (DBMS_AQ package): Example Code<br />

This example illustrates the use of the DBMS_AQ.REGISTER procedure.<br />

In the BooksOnline scenario, assume that we want a PL/SQL callback<br />

WS.notifyCB() to be invoked when the subscriber BOOKED_ORDER receives a<br />

message in the WS.WS_BOOKED_ORDERS_QUE queue. In addition, we want to send<br />

an e-mail to john@company.com when an order is enqueued in the queue for<br />

subscriber BOOKED_ORDERS. Also assume that we want to invoke the servlet<br />

http://xyz.company.com/servlets/NofifyServlet. This can be done as<br />

follows:<br />

A Sample Application Using AQ 8-103

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

Saved successfully!

Ooh no, something went wrong!