On Mon, May 19, 2008 at 9:50 PM, pratibhaG <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have to build  a solution which will take all the error  messages in a
> queue. The errors may be business errors (my customerrors) , any java 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 need 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?

It looks like you need to make sure that the messages are being passed
to the CamelErrorHandler using a wiretap so that you can output the
messages to a convenient place for counting and viewing. See either
the servicemix-eip wiretap or the Camel wiretap:

http://servicemix.apache.org/servicemix-eip.html#servicemix-eip-WireTap
OR
http://activemq.apache.org/camel/wire-tap.html

Bruce
-- 
perl -e 'print unpack("u30","D0G)[EMAIL 
PROTECTED]&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache Camel - http://activemq.org/camel/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/

Blog: http://bruceblog.org/

Reply via email to