Broker 10.5 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Subscribing to and Receiving Events | Receiving Events in the Get-Events Model | Getting Multiple Events
Getting Multiple Events
Your application may use the awGetEvents function to retrieve multiple events with a single function call, instead of calling awGetEvent to retrieve events one at a time.
The following example shows how the subscribe1.c sample application might be altered to use the awGetEvents function. The function accepts these parameters:
*A BrokerClient handle.
*The maximum number of events you want to be returned.
*The number of milliseconds to wait for an event, if no events are currently available. Set this to AW_INFINITE if you want to block indefinitely.
*A long pointer that will point to the number of events returned.
*An array of BrokerEvent pointers that will point to the events that were retrieved.
. . .
int i;
long receive_attempts = 10;
long number_received;
BrokerClient c;
BrokerEvent *e;
. . .
/* Loop getting events */
count = 1;
while(count <= receive_attempts) {
err = awGetEvents(c, MAX_EVENTS, AW_INFINITE,
&number_received, &e);
if (err != AW_NO_ERROR) {
printf("Error on getting events\n%s\n",
return 0;
for(i = 0; i < number_received; i++) {
/* process an event */
. . .
. . .
The awGetEvents function automatically acknowledges all previously received events for the Broker client. It does not acknowledge the events that were just retrieved. See Managing Event Types for more information on acknowledging events.