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.

AQ and Memory Usage<br />

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

break;<br />

}<br />

exit(-1);<br />

} /* end checkerr */<br />

Dequeuing Messages (Reuse Memory) Using OCI<br />

This program, deqreuse.c, dequeues each line of text from a queue 'msgqueue'<br />

that has been created in scott's schema by executing create_types.sql.<br />

Messages are enqueued using enqnoreuse.c or enqreuse.c. If there are no<br />

messages, it waits for 60 seconds before timing out. In this program, the dequeue<br />

subroutine reuses client side objects' memory between invocation of LNOCIAQDeq.<br />

During the first call to LNOCIAQDeq, OCI automatically allocates the memory for<br />

the message payload. During subsequent calls to LNOCIAQDeq, the same payload<br />

pointers are passed and OCI will automatically resize the payload memory if<br />

necessary.<br />

#ifndef OCI_ORACLE<br />

#include <br />

#endif<br />

#include <br />

static void checkerr(OCIError *errhp, sword status);<br />

static void deqmesg(text *buf, ub4 *buflen);<br />

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 />

A-84 <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!