Product Documentation

FairCom ISAM for C

Previous Topic

Next Topic

Retrieving the Number of Messages in a Server-Side Queue

ctSysQueueCount can be used to obtain the number of messages waiting in the server-side queue (system queue). The syntax for ctSysQueueCount() is:

ctCONV NINT ctDECL ctSysQueueCount(NINT qhandle)

Parameter qhandle is a system queue handle returned by a call to ctSysQueueOpen(). ctSysQueueCount() returns the number of messages in queue, or a negative number on error.

Example

#include <ctreep.h>


int main(void)

{

NINT eRet = 0;

NINT hQueue = -1;

NINT isam_init = 0;

NINT count;


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

}

isam_init++;

/* create a new queue */

hQueue = ctSysQueueOpen("MyQueue", 0);

if (hQueue < 0)

{

eRet = -hQueue;

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

goto Exit;

}

/* retrieve the number of messages in queue */

count = ctSysQueueCount(hQueue);

if (count < 0)

{

eRet = -count;

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

goto Exit;

}

printf("Number of messages in queue: %d\n", count);


Exit:

/* close the queue */

if (hQueue >= 0)

{

eRet = ctSysQueueClose(hQueue);

if (eRet != NO_ERROR)

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

}

if (isam_init)

CLISAM();

return (int)eRet;

}

TOCIndex