camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roman Kalukiewicz" <roman.kalukiew...@gmail.com>
Subject Re: Camel 1.2 - CatchProcessor not working?
Date Tue, 06 Nov 2007 11:48:38 GMT
2007/10/25, Nicky Sandhu <karajdaar@gmail.com>:
>
> Hi Hendrik,
>  Good catch. I have opened an issue
> (https://issues.apache.org/activemq/browse/CAMEL-191) and submitted a patch
> for review.
> Nicky

I can see the same problem with exception() construct.

exception(Exception.class).setBody(constant("error!!!!!!")).to("log:test");

unfortunately this doesn't work as exeption is not cleared.

I've created CAMEL-210 issue to track this.

Romek

> Hendrik S. wrote:
> >
> > Hi,
> >
> > We have used camel 1.1 for our project and wanted to upgrade to 1.2 (We
> > were missing the @Headers Tag in 1.1).
> >
> > But we found a bug in the try - catch handler: I the catch block is a
> > pipline, the pipline (in the catch block) detects that the exchange has
> > failed and aborts the catch handler. :(
> >
> > I've worte a simple unit test to demonstrate this:
> >
> > public class TestTryCatch {
> >
> >   public class MyBean {
> >
> >     public void process( Object obj ) {
> >       if( obj instanceof Integer )
> >         Logger.getLogger( TestTryCatch.MyBean.class ).info( "processing
> > Integer: " + obj );
> >       else
> >         throw new IllegalArgumentException( "Need an Integer, please!" );
> >     }
> >
> >   }
> >
> >   public class MyOtherBean {
> >
> >     public void process( Object obj ) {
> >       Logger.getLogger( TestTryCatch.MyBean.class ).info( "processing: " +
> > obj );
> >     }
> >
> >   }
> >
> >   @Test
> >   public void test() throws Exception {
> >     Registry registry = new Registry() {
> >
> >       public Object lookup( String name ) {
> >         return null;
> >       }
> >
> >       public <T> T lookup( String name, Class<T> type ) {
> >         return null;
> >       }
> >
> >     };
> >
> >     CamelContext cc = new DefaultCamelContext( registry );
> >
> >
> >     @SuppressWarnings("unchecked")
> >     final Endpoint<Exchange> in = cc.getEndpoint( "direct:in" );
> >     @SuppressWarnings("unchecked")
> >     final Endpoint<Exchange> out = cc.getEndpoint( "log:out" );
> >     @SuppressWarnings("unchecked")
> >     final Endpoint<Exchange> error = cc.getEndpoint( "log:error" );
> >
> >     final MyBean myBean = new MyBean();
> >     final MyOtherBean otherBean = new MyOtherBean();
> >
> >     cc.addRoutes( new RouteBuilder() {
> >
> >       @Override
> >       public void configure() throws Exception {
> >         RouteType s = from(in);
> >
> >         TryType t = s.tryBlock();
> >         t.bean( myBean ).to( out );
> >         t.handle( java.lang.Exception.class ).bean( otherBean ).to( error
> > );
> >       }
> >
> >     } );
> >
> >     cc.start();
> >
> >     CamelTemplate<Exchange> t = new CamelTemplate<Exchange>(cc);
> >     t.sendBody( in, Integer.valueOf( 10 ) );
> >
> >     t.sendBody( in, "This will fail..." ); // the catch handler will not
> > process this correctly!
> >
> >     Thread.sleep( 1000 );
> >
> >   }
> >
> > }
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Camel-1.2---CatchProcessor-not-working--tf4690438s22882.html#a13414030
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message