camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Camel 1.2 - CatchProcessor not working?
Date Fri, 26 Oct 2007 11:53:56 GMT
Patch applied with thanks! :)

On 25/10/2007, Hendrik S. <hendriks@spohr.vol.at> 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#a13405439
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


-- 
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com

Mime
View raw message