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 callback event notification

Callback event processing for basic delivery

When the event is created at the EIS end, configured adapterListener gets notified and it in turn instantiates CallbackEventSender. Here adapterListener decides which method to invoke out of the four defined.

To implement callback mechanism, adapter must have an EndPointManager class. The class needs to maintain the relationship between the activationSpec and MessageEndpointFactory arguments. Here is a snippet of EndPointManager class showing how the callback mechanism is implemented.

public class EndpointManager {

	/**
	* inner class which maintains pairs of mef and activationspec
	*/
      public static class EndpointPair {
       public MessageEndpointFactory mef;

       public ActivationSpec activationSpec;

       public EndpointPair(MessageEndpointFactory mef,  ActivationSpec activationSpec) {
            this.mef = mef;
            this.activationSpec = activationSpec;
        } 
        	public boolean equals(Object o) {
            if (!(o instanceof EndpointPair)) {
                return false;
            		} 
            	EndpointPair other = (EndpointPair) o;
return other.mef.equals(this.mef) && other.activationSpec.equals
(this.activationSpec);
                   }        } 
// adds new endpointPair to the list
public void addEndpoint(MessageEndpointFactory mef, ActivationSpec activationSpec) 
throws ResourceException {…} } 

The adapter listener gets all MessageEndpointFactories for the current activationSpec and registers that with the CallbackEventSender instance.

EndpointManager epManager =  ((ResourceAdapter)aSpec.getResourceAdapter())
.getEndpointManager();
EndpointPair[] endpoints = epManager.getEndpoints(this.aSpec);

if (!isSynchronous && aSpec.getAssuredOnceDelivery().booleanValue()) 
{// XA Delivery
	callbackEventSender = new CallbackEventSender(endPointList, 		 eventRecMngr.getEventPersistance(), XAres, aSpec, 		 logger.getLogUtils());
	} else {// Non XA delivery
		 callbackEventSender = new CallbackEventSender(endPointList, 		 aSpec, logger.getLogUtils());

Refer to the section on Callback event sender constructors for more information. The adapter listener creates the worker threads to take care of calling and getting responses from the callBackEventSender method.

Once the program control gets into CallbackEventSender, it checks how many EndpointFactories are configured for the current instance of adapter. If there is more than one, then it delivers the event by creating endpoints for each of them and invoking either onNotification or onMessage method on the endpoint with out any XA transaction. Finally, it would call the release() method on the end point to free the endpoint hence the application server can add it to endpoint pool.

Also it invokes beforeDelivery() and afterDelivery() methods on the endpoint as defined by the JCA functional specification.

XA transaction will come into picture only when the adapter is configured with ONE EndpointFactory. The following sequence diagram depicts the callback event processing for basic delivery.

Inbound callback event notification


Related concepts:

Request and response callback events

One-way callback events

Use the IBM WebSphere adapter foundation classes for inbound callback event processing

Callback event sender

Callback event processing for event delivery with XA transaction

Callback event processing for event recovery