Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Subscribing to and Receiving Events | Receiving Events in the Get-Events Model | Synchronous Get Events
 
Synchronous Get Events
To specify a synchronous get events using any of the BrokerClient.getEvent or BrokerClient.getEvents methods, you must use the BrokerClient.SYNCHRONOUS definition as the timeout value for the methods.
If the Broker receives the "events" protocol with its flag set to "synchronous" then the Broker will either:
*Return any available events up to the maximum number of requested events
*Immediately return indicating that no events are available.
When there are no events available, the Broker will not submit a pending request for events on behalf of the client.
If the Broker API requests a synchronous get events, one of the following can occur:
*If the Broker does not return with a response within the default Broker timeout, then a BrokerTimeoutException will be thrown.
*If the Broker returns with events, then the events are returned by the get events method.
*If the Broker returns an indication that no events are available then the Broker client's get events methods will return both of the following:
*A null for the Brokerclient.getevent methods
*A zero-length BrokerEvent array for the BrokerClient.getEvents methods
The example below shows the use of synchronous get events using the BrokerClient.getEvent and BrokerClient.getEvents methods. To specify synchronous get events, set the timeout value to the BrokerClient.SYNCHRONOUS.
// Example 1
BrokerClient client;
BrokerEvent event = client.getEvent(BrokerClient.SYNCHRONOUS);
if (event != null) {
process(event);
}
 
// Example 2
BrokerClient client;
BrokerEvent[] events = client.getEvents(10, BrokerClient.SYNCHRONOUS);
if (events.length > 0) {
process(events);
}
For more information, see the BrokerClient.getEvent and BrokerClient.getEvents methods.