If an error occurs (for example, event data is corrupted or the broker is unavailable) that causes event delivery to fail, the error must be communicated to the external application. The external application can then decide whether to correct the error (for example, by correcting the data and resending it or by attempting broker re-start).
An interface error handler is provided with the adapter. It has methods for handling errors in event as well as request processing. Use the information in this appendix to implement the methods.
These methods collect the error-related information from the adapter runtime (for example, whether the error occurred during "event" or "response to event", which component caused the error (data handler, message handler, or broker), what was the exact exception thrown, what was the originating event, and so on).
This feature is currently used in at message handler, data handler, and broker error checkpoints. The method invoked during inbound flow/event processing is handleEventError.
The following is a list of checkpoints for the HL7 sample that is provided with the adapter. They translate to equivalent checkpoints in custom implementations.
The following section provides information you can use to implement the interface. Note that handleEventError is the method of Error Handler that is invoked in event processing.
This section also lists some predefined values provided for the input parameters. The predefined values are underlined.
package com.ibm.adapters.protocol.util; import com.crossworlds.cwconnectorapi.CWConnectorBusObj; public interface ErrorHandler { //output string will be written to the client socket's output stream // the content of this string is the responsibility of error handler //implementer
public String handleEventError( byte[] event, //data over input stream of the socket byte[] errorData, //portion of input bytes which caused error, as the input data can contain multiple messages (see SupportMultipleMessages in Service MO), out of which only some portion can be invalid. This parameter tells which exact portion contains invalid data. String errorLocation, //MessageHandler/DataHandler/Broker Object exceptionObj, //actual exception String flow //event/responseToEvent ); public String handleRequestError( CWConnectorBusObj currBusObj,//BO from broker String errorLocation, //MessageHandler/DataHandler/Broker Object exceptionObj, //actual exception String flow //request/responseToRequest ); }
The return type of the method handleEventError should be the string that is written back to the calling TCP/IP client.