Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client C API Programmer's Guide | Subscribing to and Receiving Events | Receiving Events in the Get-Events Model
 
Receiving Events in the Get-Events Model
 
Getting Multiple Events
Subscription Identifiers
BrokerSubscription Objects
The simplest way to retrieve events is to use the get-events model, in which your application follows these steps:
1. Create a BrokerClient pointer.
2. Use the BrokerClient to subscribe to one or more event types. If your Broker client only expects to receive delivered events, no subscriptions are necessary.
3. Enter a processing loop in which awGetEvent is called to retrieve the next event. You can use the awInterruptGetEvents function if you need to interrupt the a previous call to awGetEvent or awGetEvents.
4. Extract the desired fields from each received event using the functions described in Getting Started.
5. Call awDeleteEvent to free the event when you are finished processing it.
6. Return to step 3 and receive the next event.
7. Call awDestroyClient when you are finished.
The following example contains an excerpt from the subscribe1.c sample application that shows the use of the awGetEvent function. The function accepts these parameters:
*A BrokerClient handle.
*The number of milliseconds to wait for an event, if none are currently available. This may be set to AW_INFINITE if you want to block indefinitely.
*A BrokerEvent pointer.
. . .
BrokerEvent e;
. . .
/* Loop getting events */
count = 1;
while(count <= num_to_receive) {
err = awGetEvent(c, AW_INFINITE, &e);
if (err != AW_NO_ERROR) {
printf("Error on getting event\n%s\n",
awErrorToString(err));
return 0;
}

/* process the event */
. . .

awDeleteEvent(e);
++count;
}
. . .
Note:
The awGetEvent function automatically acknowledges all previously received events for the Broker client. It does not acknowledge the event that was just retrieved. See Using Sequence Numbers for more information on acknowledging events.