You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nuskhu <ar...@cnamts.fr> on 2016/03/22 14:11:22 UTC

problem with exception in the recipientList

hi,
I think that i meet a problem with the recipientList when an endpoint throw
an exception.

this code work :

 from("direct:rlAggregate").process(
new Processor() { 
String   destinations = "bean:throwingExceptionConsumerB, bean:consumerC";}
})
                .recipientList(header("destinations"), ",")
.parallelProcessing().
aggregationStrategy(agg);

an this one not :

 from("direct:rlAggregate")
                .process(new Processor() { String   destinations =
"bean:consumerC, bean:throwingExceptionConsumerB";} })
                .recipientList(header("destinations"),
",").parallelProcessing().aggregationStrategy(agg);

it's throwing the exception :

org.apache.camel.CamelExecutionException: Exception occurred during
execution on the exchange

They should have the same results and only the option stopOnException should
allow to stop when an Exception rise from an endpoint.

thanks



--
View this message in context: http://camel.465427.n5.nabble.com/problem-with-exception-in-the-recipientList-tp5779499.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem with exception in the recipientList

Posted by nuskhu <ar...@cnamts.fr>.
here is the code:

public class AggregationSimple implements AggregationStrategy {

    /** Logger de la classe. */
    private static final Logger LOGGER =
Logger.getLogger(AggregationSimple.class);

 
    public Exchange aggregate(final Exchange pOldExchange,
            final Exchange pNewExchange) {

        if (pOldExchange == null) {

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("1er passage   " + pNewExchange);
            }

            final String text = pNewExchange.getIn().getBody(String.class);

            pNewExchange.getIn().setBody(text);
        } else {

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Aggregation de : " + pOldExchange + "/" +
pNewExchange);
            }

            final String text = pOldExchange.getIn().getBody(String.class);
            final String text2 = pNewExchange.getIn().getBody(String.class);

            pNewExchange.getIn().setBody(text + "/aggregation/" + text2);
        }
        return pNewExchange;
    }
}




--
View this message in context: http://camel.465427.n5.nabble.com/problem-with-exception-in-the-recipientList-tp5779499p5779511.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem with exception in the recipientList

Posted by Claus Ibsen <cl...@gmail.com>.
What is your aggregation strategy source code. It depends how you
handle it there. S

On Tue, Mar 22, 2016 at 2:38 PM, nuskhu <ar...@cnamts.fr> wrote:
> It's a valid endpoint, it's just throwing an exception to check the behaviour
> of the recipiantList :
>
> @Component
> public class ThrowingConsumerB {
>
>     private static final Logger LOGGER =
> LoggerFactory.getLogger(ThrowingConsumerB.class);
>
>     public String sayHello(@Body String message) {
>         LOGGER.info("B");
>         message += " B";
>         LOGGER.debug(message);
>
>         try {
>             Thread.sleep(1000L);
>         } catch (InterruptedException e) {
>             e.printStackTrace();
>         }
>
>         throw new RuntimeException("BOUM !");
>
>     }
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-with-exception-in-the-recipientList-tp5779499p5779508.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: problem with exception in the recipientList

Posted by nuskhu <ar...@cnamts.fr>.
It's a valid endpoint, it's just throwing an exception to check the behaviour
of the recipiantList :

@Component
public class ThrowingConsumerB {

    private static final Logger LOGGER =
LoggerFactory.getLogger(ThrowingConsumerB.class);

    public String sayHello(@Body String message) {
        LOGGER.info("B");
        message += " B";
        LOGGER.debug(message);

        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        throw new RuntimeException("BOUM !");

    }
}



--
View this message in context: http://camel.465427.n5.nabble.com/problem-with-exception-in-the-recipientList-tp5779499p5779508.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem with exception in the recipientList

Posted by Claus Ibsen <cl...@gmail.com>.
No there is an option to ignore invalid endpoints you need to turn on
http://camel.apache.org/recipient-list.html



On Tue, Mar 22, 2016 at 2:11 PM, nuskhu <ar...@cnamts.fr> wrote:
> hi,
> I think that i meet a problem with the recipientList when an endpoint throw
> an exception.
>
> this code work :
>
>  from("direct:rlAggregate").process(
> new Processor() {
> String   destinations = "bean:throwingExceptionConsumerB, bean:consumerC";}
> })
>                 .recipientList(header("destinations"), ",")
> .parallelProcessing().
> aggregationStrategy(agg);
>
> an this one not :
>
>  from("direct:rlAggregate")
>                 .process(new Processor() { String   destinations =
> "bean:consumerC, bean:throwingExceptionConsumerB";} })
>                 .recipientList(header("destinations"),
> ",").parallelProcessing().aggregationStrategy(agg);
>
> it's throwing the exception :
>
> org.apache.camel.CamelExecutionException: Exception occurred during
> execution on the exchange
>
> They should have the same results and only the option stopOnException should
> allow to stop when an Exception rise from an endpoint.
>
> thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/problem-with-exception-in-the-recipientList-tp5779499.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2