camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dariusz.skrudlik" <dariusz.skrud...@gmail.com>
Subject How catch exception with endpoint was created dynamicly
Date Fri, 09 Aug 2013 14:13:49 GMT
I found a lot of post about that, but any working for me.

I have tested options
- throwExceptionOnConnectFailed
- consumer.bridgeErrorHandler
- pollStrategy


I have spring bean where define route:

@Service
public class MyRouteRunner {

    @Autowired
    CamelContext camelContext;

    public void startRoute( /* some arguments */) {

        route =
"ftp:username@ftp.com.pl?pollStrategy=#myPollStrategy&throwExceptionOnConnectFailed=true&consumer.bridgeErrorHandler=true";

        Exchange exchange = null;
        ConsumerTemplate consumerTemplate =
camelContext.createConsumerTemplate();

        Endpoint endpoint = camelContext.getEndpoint(route);
        consumerTemplate.start();
        exchange = consumerTemplate.receive(endpoint, 2000);

        // I NEED EXCEPTION HERE because must perform extra action depends
for argument

}

I have also own PoolStrategy bean

public class FtpConsumerPollStrategy implements PollingConsumerPollStrategy
{

 
    @Override
    public boolean rollback(Consumer consumer, Endpoint endpoint, int
retryCounter, Exception e) throws Exception {

        //HERE I GET EXCEPTION but any code don't propagate exception to
main bean
//1
// throw e; // this should work

//2
//        Exchange exchange = endpoint.createExchange();
//        exchange.setException(e);
//       ((FtpConsumer)consumer).getProcessor().process(exchange);

        return false;
    }
}

Generally when all is ok and file on server exists I receive it, but when
exception occurs then I cann't perform any  action.
How can I handle exception where I need it ?




--
View this message in context: http://camel.465427.n5.nabble.com/How-catch-exception-with-endpoint-was-created-dynamicly-tp5737037.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message