Hi,
I have a question regarding servicemix error handling.
I need a solution which will take all my error messages in a queue. The
errors may be business errors (my customerrors) , any javas code errors or
other errors when my application is down. How can I achieve this.

I tried an example with camel, jms and bean.

I want it to work like this.
camel will take a message from jmsconsumer and pass it to bean. If inside
bean the status of MessageExchange becomes ERROR then the message should be
sent to another queue.

my jms 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.queue3"
       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.queue10"
       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>




my camelcontext.xml

<beans xmlns="http://www.springframework.org/schema/beans";>

        <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring";>
        <package>errorhandling.camel</package>
        </camelContext>

</beans>


My error Handler:

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));
           from(SERVICE_IN).to(BEAN_IN);
        }

}


my beans xbean.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:bean="http://servicemix.apache.org/bean/1.0";
           xmlns:esb="http://esbinaction.com/errorhandling";>

        <bean:endpoint service="esb:errorComponent" 
                endpoint="errorEndpoint" 
                bean="#errorBean"/>
  
        <bean id="errorBean" class="errorhandling.ErrorComponent" />

</beans>


my bean:

package errorhandling;

import javax.annotation.Resource;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;

import org.apache.servicemix.MessageExchangeListener;

public class ErrorComponent implements MessageExchangeListener {

        @Resource
        private DeliveryChannel channel;

    public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
        //String test = null;
        //test.equals("test");
        exchange.setError(new NullPointerException("myexception"));
        exchange.setStatus(ExchangeStatus.ERROR);
        channel.send(exchange);
    }
}

I expect that all my messages should go in queue tutorial.camel.queue10, but
it is not happening so. messages are consumed from queue
tutorial.camel.queue3 but they are not reaching tutorial.camel.queue10. 

Please help me to understand why so? I mistake I am committing?

Regard,
Pratibha

-- 
View this message in context: 
http://www.nabble.com/ServiceMix-Error-Handling-tp17316666p17316666.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to