Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Creating or Opening a Server-Side Queue

Before any operation can be attempted with a server-side queue (system queue), a process must create a new queue, or open an existing queue, by calling the function:

ctCONV NINT ctDECL ctSysQueueOpen(pTEXT qname,NINT qmode);

Parameter qname identifies the queue to be opened. If the queue specified by qname does not exist, a new queue is created. Parameter qmode is currently reserved for future use and should be set to zero. ctSysQueueOpen() returns a queue handle on success, or a negative number as the error code.


#include <ctreep.h>

int main(void)


NINT eRet = 0;

NINT hQueue = -1;

TEXT buffer[256];

NINT isam_init = 0;

/* init ISAM */

eRet = (NINT)INTISAMX(6, 7, 4, 6, 0, "ADMIN", "ADMIN", "FAIRCOMS");

if (eRet != NO_ERROR)


printf("INTISAM failed with error %d\n", eRet);

goto Exit;



/* create a new queue */

hQueue = ctSysQueueOpen("MyQueue", 0);

if (hQueue < 0)


eRet = -hQueue;

printf("ctSysQueueOpen failed with error %d\n", eRet);

goto Exit;


/* wait 100 ms for a new message */

eRet = ctSysQueueRead(hQueue, buffer, sizeof(buffer), 100);

/* check if read time-out */

if (eRet == NO_ERROR)

printf("ctSysQueueRead succeeded\n");

else if (eRet == NTIM_ERR)

printf("ctSysQueueRead time-out\n");


printf("ctSysQueueRead failed with error %d\n", eRet);


/* close the queue */

if (hQueue >= 0)


eRet = ctSysQueueClose(hQueue);

if (eRet != NO_ERROR)

printf("ctSysQueueClose failed with error %d\n", eRet);


if (isam_init)


return (int)eRet;