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.

struct message<br />

{<br />

OCINumber id;<br />

OCIString *data;<br />

};<br />

typedef struct message message;<br />

struct null_message<br />

{<br />

OCIInd null_adt;<br />

OCIInd null_id;<br />

OCIInd null_data;<br />

};<br />

typedef struct null_message null_message;<br />

/* Global data reused on calls to enqueue: */<br />

LNOCIEnv *envhp;<br />

LNOCIError *errhp;<br />

LNOCISvcCtx *svchp;<br />

message msg;<br />

null_message nmsg;<br />

LNOCIAQMsgProperties *msgprop;<br />

AQ and Memory Usage<br />

static void enqmesg(msgno, buf)<br />

ub4 msgno;<br />

text *buf;<br />

{<br />

OCIType *mesgtdo = (OCIType *)0; /* type descr of SCOTT.MESSAGE */<br />

message *mesg = &msg; /* instance of SCOTT.MESSAGE */<br />

null_message *mesgind = &nmsg; /* null indicator */<br />

text corrid[128]; /* correlation identifier */<br />

/* Get the type descriptor object for the type SCOTT.MESSAGE: */<br />

checkerr(errhp, OCITypeByName(envhp, errhp, svchp,<br />

(CONST text *)"SCOTT", strlen("SCOTT"),<br />

(CONST text *)"MESSAGE", strlen("MESSAGE"),<br />

(text *)0, 0, OCI_DURATION_SESSION,<br />

OCI_TYPEGET_ALL, &mesgtdo));<br />

/* Fill in the attributes of SCOTT.MESSAGE: */<br />

checkerr(errhp, OCINumberFromInt(errhp, &msgno, sizeof(ub4), 0, &mesg->id));<br />

checkerr(errhp, OCIStringAssignText(envhp, errhp, buf, strlen(buf),<br />

&mesg->data));<br />

mesgind->null_adt = mesgind->null_id = mesgind->null_data = 0;<br />

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

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

Saved successfully!

Ooh no, something went wrong!