134 WebSphere Business Integration Adapters
Table 8-20 Method for releasing event-store resources
For example, if the event store is implemented as event tables in a database, the
pollForEvents() method might allocate SQL cursors to access these tables.
You can implement a cleanupResources() method to free these SQL cursors. At
the end of pollForEvents(), you can then call the cleanupResources() method
to free the memory that these cursors use.
8.5 Processing delete events
An application can support one of the following types of delete operations:
Physical delete (data is physically deleted from the database).
Logical delete (a status column in a database entity is set to an inactive or
invalid status, but the data is not deleted from the database).
It might be tempting to implement delete event processing in a manner that is
consistent with the application. For example, when an application entity is
deleted, a connector poll method for an application that supports physical deletes
might publish a business object with the Delete verb. A connector poll method for
an application that supports logical deletes might publish a business object with
the Update verb and the status value changed to inactive.
Problems can arise with this approach when a source application and a
destination application support different delete models. Suppose that the source
application supports logical delete and the destination application supports
physical delete. Assume that an enterprise is synchronizing between the source
and destination applications. If the source connector sends a change in status (in
other words, a delete event) as a business object with the Update verb, the
destination connector might be unable to determine that the business object
actually represents a delete event.
Therefore, event publishing must be designed so that source connectors for both
types of applications can publish delete events in such a way that destination
connectors can handle the events appropriately. The Delete verb in an event
notification business object should represent an event where data was deleted,
Java connector library class Method
CWConnectorEventStore cleanupResources()
Note: The CWConnectorEventStore class does not provide a default
implementation of the cleanupResources() method. To free event-store
resources, you must override the cleanupResources() method with a version
that releases the resources needed to access your event store.
Chapter 8. Asynchronous event processing and notification 135
whether the delete operation was a physical or logical delete. This ensures that
destination connectors will be correctly informed about a delete event.
8.5.1 Setting the verb in the event record
The event detection mechanism for both logical and physical delete connectors
should set the verb in the event record to Delete:
For a physical delete connector, this is the standard implementation.
For a connector whose application supports logical deletes, the event
detection mechanism must be designed to determine when update events
actually represent deletion of data.
In other words, it must differentiate update events for modified entities from
update events for logically deleted entities. For logically deleted entities, the
event detection mechanism should set the verb in the event record to Delete
even if the event in the application was an Update event that updated a status
column.
8.5.2 Setting the verb in the business object
The poll method for both logical and physical delete connectors should generate
a business object with the Delete verb:
If the application supports logical deletes, the connector poll method retrieves
the delete event from the event store, creates an empty business object, sets
the key, sets the verb to Delete, and sends the business object to the Adapter
Framework.
For hierarchical business objects, the connector should not send deleted
children. The connector can constrain queries to not include entities with the
status of inactive, or child business objects with a status of inactive can be
removed in mapping.
If the application supports physical deletes, the connector might not be able to
retrieve the application data. In this case, the connector poll method retrieves
the delete event from the event store, creates an empty business object, sets
the key values, sets the values of other attributes to the special Ignore value
(CxIgnore), sets the verb in the business object to Delete, and sends the
business object to the Adapter Framework.

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.