282 WebSphere Business Integration Adapters
The fetchEvents() method uses the private fetchEvents (pollQuantity, status)
method, as shown in Example 17-3.
Example 17-3 The private fetchEvents(pollQuantity, status) method
private Vector fetchEvents(int pollQuantity, int status)
throws StatusChangeFailedException {
RMLogger.trace(RMLogger.LEVEL4, "Entering fetchEvents(int, int)");
Vector fetchedEvents = new Vector();
// obtain connection from connection pool
RMServerRMIInterface connection;
try {
connection = (RMServerRMIInterface) connectionPool.getConnection();
} catch (Exception e) {
CWConnectorExceptionObject c = new CWConnectorExceptionObject();
c.setMsg("Unable to obtain connection to the application");
c.setStatus(CWConnectorConstant.APPRESPONSETIMEOUT);
throw new StatusChangeFailedException(c);
}
// retrieve <pollQuantity> number of <status> events from the event table
try {
// for each event retrived...
String eventId = "0";
boolean otherEvents = true;
int eventRetrieved = 0;
while (otherEvents && eventRetrieved < pollQuantity) {
//get the RMDataImplementation object
RMDataImplementation inpDataImpl =
getRMDataImplementationInstance(eventId, status);
//...retrieve the object
try {
RMDataImplementation outDataImpl =
(RMDataImplementation) connection.retrieveObject(
inpDataImpl);
// ...create a CWConnectorEvent object...
CWConnectorEvent aEvent =
getEventFromRMDataImplementation(outDataImpl);
//...save the key for the next event to retrieve...
eventId = aEvent.getEventID();
// ... and add it to the vector of fetched events
fetchedEvents.addElement(aEvent);
eventRetrieved++;
} catch (RemoteException e) { //no other events to retrieve
otherEvents = false;