Prathiba,
Could you try setting the log level for ServiceMix to DEBUG? This will
allow you to see which MessageExchanges are being handled by the ESB
(together with their status ACTIVE/ERROR/DONE) so you can compare what's
different when you add the listener. Looking at your code, it only
seems to replace the MessageExchange's error with a custom Exception, so
that should be OK I guess...
Gert
pratibhaG wrote:
I included the listener like this
<sm:services>
<sm:statistics statsInterval="10" dumpStats="true" />
</sm:services>
<sm:listeners>
<bean id="errorBean" class="errorhandling.ExceptionListenerService"
/>
</sm:listeners>
and I tried this example:
example: take a message from queue tutorial.camel.queue13 and pass it to a
bean. The bean sets the message status to error. As the status is error the
message is put in queue tutorial.camel.queue1
here are some of the files of the example:
jms-su xbean.xml
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
xmlns:esb="http://esbinaction.com/errorhandling">
<jms:endpoint service="esb:errorHandlerDSL"
endpoint="errorEndpoint"
role="consumer"
destinationStyle="queue"
jmsProviderDestinationName="tutorial.camel.queue13"
defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
connectionFactory="#connectionFactory"/>
<jms:endpoint service="esb:errorStorageService"
endpoint="errorStorageEndpoint"
role="provider"
destinationStyle="queue"
jmsProviderDestinationName="tutorial.camel.queue1"
defaultMep="http://www.w3.org/2004/08/wsdl/in-only"
connectionFactory="#connectionFactory"/>
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
</beans>
camel route builder java file
package errorhandling.camel;
import org.apache.camel.builder.RouteBuilder;
public class CamelErrorHandler extends RouteBuilder {
private final static String NAMESPACE =
"http://esbinaction.com/errorhandling";
private final static String SERVICE_IN = "jbi:service:" +
NAMESPACE + "/errorHandlerDSL";
private final static String BEAN_IN = "jbi:service:" +
NAMESPACE + "/errorComponent";
private final static String ERROR_IN = "jbi:service:" +
NAMESPACE + "/errorStorageService";
public void configure() {
/*errorHandler(deadLetterChannel(ERROR_IN).maximumRedeliveries(2));
from(SERVICE_IN).to(BEAN_IN);*/
from(SERVICE_IN).errorHandler(deadLetterChannel(ERROR_IN).maximumRedeliveries(1)).to(BEAN_IN);
//from(SERVICE_IN).errorHandler(noErrorHandler).to(BEAN_IN);
}
}
Now if I don't put
<sm:listeners>
<bean id="errorBean" class="errorhandling.ExceptionListenerService"
/>
</sm:listeners>
in conf/servicemix.xml then the example works fine. That is the message is
consumed from tutorial.camel.queue13 and is routed to tutorial.camel.queue1
as i am setting message status to error in my bean.
But if I put
<sm:listeners>
<bean id="errorBean" class="errorhandling.ExceptionListenerService"
/>
</sm:listeners>
in conf/servicemix.xml then the example does not work as expected. That is
the message is consumed from tutorial.camel.queue13 but not routed to
tutorial.camel.queue1 even when i am setting message status to error in my
bean.
Is it the same way the listener is supposed to behave or am I missing
something.
Another thing is that I never saw the message "The following error was
caused by service" which is created in my listener. Where this message will
be shown?
-Pratibha