ESB

Error Handling

Functionality

This sample shows how to handle errors or exceptions occured and handle them appropriately.

Default Behaviour

This component sends to the output port the same message that it receives on the input port.

Changes made in the component

  1. In the service references under "servicerefs" element in ServiceDescriptor.xml

    Add

    <serviceref guid="EDBCEngine" version="4.0" />
    <serviceref guid="TifosiJavaRTL" version="4.0" />
    

    Remove

    <serviceref guid="FioranoJavaRTL" version="4.0" /> 
    
  2. Add an additional runtime-argument in ServiceDescriptor.xml under 'execution' element as shown below:

    <runtime-argument name="retryCount" mandatory="false">
    	<value>5</value>
    </runtime-argument>
    
  3. Make the changes below.

Elements

Changes Required

ErrorHandling.java

Create field static String[] arguments;
Modify the method void main(String[]) to initialize 'arguments' variable.
Modify the void onException(JMSException) method of class ErrorHandlingExceptionListener to handle restarting the component the number of times as specified for the runtime argument 'retryCount'.

ErrorHandlingMessageListener.java 

Modify the void onMessage(Message) method to handle the default behaviour of the component.

  • To check the functionality of this component, it should be registered with the server.

  • The steps to register the samples is specified in the Sample Templates section.