IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Services and service-related functions > Access external services with adapters > Configure and using adapters > IBM WebSphere Adapters > Adapter Toolkit > Implementing code from the IBM WebSphere Adapter Toolkit > Inbound event notification

Implementing event retrieval in the adapter

The careful work of implementing event retrieval in the adapter uses two Foundation Classes interfaces. The goals are setting up event polling and a safe, reliable connection to the event store.

Adapters that employ the Foundation Classes for event retrieval must meet the following requirements:

  1. Implementing interface com.ibm.j2ca.base.WBIPollableResourceAdapterWithXid in any WBIResourceAdapter subclass.
  2. Implementing interface com.ibm.j2ca.extensions.eventmanagement.EventStoreWithXid

The first requirement identifies (for the Foundation Classes) the adapter for event polling. If this interface is implemented, the Foundation Classes automatically begin checking for and publishing events as dictated by polling-related configuration properties such as PollPeriod and PollQuantity and as specified by active adapter endpoints.

The second requirement, implementation of the EventStoreWithXid interface, typically requires the most (adapter) development effort. As the location and structure of each event store is application-specific, the EventStoreWithXid interface provides the Foundation Classes with a common means of querying and modifying an event store.


Implementing an EventStore Interface

An EventStore implementation is responsible for establishing and managing a connection, if necessary, to the underlying EIS application. The EventStore implementation should be thread-safe because it will be accessed on multiple threads in Unordered delivery mode.

The table below describes the methods that each EventStore implementation must provide:

EventStore methods

Method Description
public void setEventTransactionID(Event event, XidImpl xid) throws ResourceException, CommException

This method should store the xid in the Event table in the same row specified by event. xid.toString() will serialize the Xid for easy storage.

public Xid[] getPendingTransactions() throws ResourceException, CommException

This method should return the XIDs for events that have an associated XID, but are still in NEWEVENT status.

public Event getEventForXid(XidImpl xid) throws ResourceException, CommException

This method should return the event associated with the given Xid.

ArrayList getEvents(int quantity, int eventStatus, String[] typeFilter)

This method enables the adapter to determine if there are any new events available or old events that need re-sending. Implement this method to query the event store and return a list of event instances (up to the limit specified by thequantity parameter ) that have a status matching the value of parameter eventStatus. The order of events returned in ArrayList should reflect the sequence of events as intended for publication.

If this EventStore implementation supports filtering as specified by method implementsFiltering, this method should inspect the value of parameter typeFilter. If typeFilter is not null, the method should return events that match the type(s) specified only. If typeFilter is null (or filtering is not supported), the method should simply return events of all types.

boolean implementsFiltering() This method provides the Foundation Classes with information about the capability of the EventStore implementation. If it can filter events by type in method getEvents, the implementation should return true; otherwise it should return false.
Event getSpecificEvent(String eventId) This method should reconstruct a complete event object for the event identifier. This will most likely require that the EventStore implementation query to retrieve the missing information from the event record in the EIS (for example, object type, status, and so on).
Object getObjectForEvent(Event event) The EventStore implementation should inspect the event passed and return a business object instance reflecting the changed entity in the EIS application.

For example, if the event specifies an object type of CustomerBG and a key value of CustomerID=123, this method might be expected to return a CustomerBG instance populated with the values from customer 123 in the EIS.

void deleteEvent(Event event) The EventStore implementation should delete the event record identified from the underlying EIS event store.
void updateEventStatus(Event event, int newstatus) The EventStore implementation should modify the event record identified with the provided status code.


Transaction Support Methods

If the implementation of the event store supports transactions, the EventStore implementation should provide access to that transaction control using the following methods:

EventStore transaction control methods

Method Description
boolean isTransactional() Is the event store transactional? If so, this method should return true.
void commitWork() This method should commit the pending transaction. It is required only if transactions are supported.
void rollbackWork() This method should rollback any uncommitted work. It is required only if transactions are supported.

Inbound event notification