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.

OCIAttrSet((dvoid *)svchp, (ub4)OCI_HTYPE_SVCCTX,<br />

(dvoid *)usrhp, (ub4)0, OCI_ATTR_SESSION, errhp);<br />

/* allocate the dequeue options descriptor */<br />

checkerr(errhp, OCIDescriptorAlloc(envhp, (dvoid **)&deqopt,<br />

OCI_DTYPE_AQDEQ_OPTIONS, 0, (dvoid **)0));<br />

do {<br />

deqmesg(buf, &buflen);<br />

printf("%.*s\n", buflen, buf);<br />

} while(1);<br />

AQ and Memory Usage<br />

/*<br />

* This program never reaches this point as the dequeue timesout & exits.<br />

* If it does reach here, it will be a good place to free the dequeue<br />

* options descriptor using OCIDescriptorFree and free the memory allocated<br />

* by OCI for the payload using OCIObjectFree<br />

*/<br />

} /* end main */<br />

static void checkerr(errhp, status)<br />

LNOCIError *errhp;<br />

sword status;<br />

{<br />

text errbuf[512];<br />

ub4 buflen;<br />

sb4 errcode;<br />

if (status == OCI_SUCCESS) return;<br />

switch (status)<br />

{<br />

case OCI_ERROR:<br />

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

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

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

break;<br />

case OCI_INVALID_HANDLE:<br />

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

break;<br />

default:<br />

printf("Error - %d\n", status);<br />

break;<br />

}<br />

exit(-1);<br />

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

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

Saved successfully!

Ooh no, something went wrong!