Chapter 17. Implementing event notification 281
17.2 Implementing the fetchEvents() method
The fetchEvents() method retrieves a specified number of ready-for-poll events
from the event store. This method searches the event store for event records
with the READY_FOR_POLL status and puts them in the eventsToProcess
The number of events that the fetchEvents() method retrieves is determined by
the value of the PollQuantity connector configuration property. For each retrieved
event, the method must create a CWConnectorEvent event object and put this
event object into a Java vector. The method then calls the setEventsToProcess()
method to save this event vector into the eventsToProcess vector, which is a
member of the CWConnectorEventStore object.
The fetchEvents() method determines the order in which event objects are
stored in the eventsToProcess vector.
Example 17-2 shows the fetchEvents() method implementation for the
Example 17-2 The fetchEvents() method
public void fetchEvents() throws StatusChangeFailedException {
RMLogger.trace(CWConnectorUtil.LEVEL4, "Entering fetchEvents");
// find out how many events to process per poll (n)
int pollQuantity =
// retrieve (n) number of ready for poll events from the event table
Vector fetchedEvents =
// pass the vector of event objects to setEventsToProcess()
RMLogger.trace(CWConnectorUtil.LEVEL4, "Exiting fetchEvents");
Important: The fetchEvents() method is an abstract method. Therefore, the
event-store class must implement this method to provide the ability to fetch
READY_FOR_POLL events from the event store.
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");
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(
// ...create a CWConnectorEvent object...
CWConnectorEvent aEvent =
// the key for the next event to retrieve...
eventId = aEvent.getEventID();
// ... and add it to the vector of fetched events
} catch (RemoteException e) { //no other events to retrieve
otherEvents = false;

Get WebSphere Business Integration Adapters: An Adapter Development and WebSphere Business Integration Solution now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.