Broker 10.15 | webMethods Broker Documentation | webMethods Broker Client Java API Programmer's Guide | Subscribing to and Receiving Events | Getting Events using the poll Method | Using the poll Method
 
Using the poll Method
 
A Polling Example
The following procedure describes the general steps you use the poll method to retrieve events.
1. Create the Broker clients (e.g., BrokerClient[]) whose queues you want to poll.
2. Generate an array containing a BrokerClientPoll object for each client in BrokerClient[].
3. Call the BrokerClient.poll method and pass in the BrokerClientPoll[] and a time-out interval (in milliseconds). This method will check the queue of each client represented BrokerClientPoll[]. If the method discovers at least one event in a client's queue, it sets a flag in that client's BrokerClientPoll object. If the method does not find an event in any of the client queues, it continues to poll until 1) one or more events arrive, 2) the specified timeout interval expires, 3) the thread is interrupted, whichever occurs first.
4. Loop through the BrokerClientPoll[] that the poll method returns and retrieve the events from the queues of the clients represented in that array. (The array will not contain clients whose queues were empty.)
Important:
The queues of the clients in the array have already been primed using prime(1). Your application code does not need to re-prime the queues unless you want it to fetch more than a single event.