You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by carlphilipp <cp...@gmail.com> on 2017/05/13 18:11:24 UTC

How to test redeliver messages?

Hello everybody,

I would like to make sure my redeliver logic is working. I do not find any
feature to do that.
For example, is there anyway to do:

weaveById("ws-call").replace().throwException(new RuntimeException());

This will throw the exception anytime, what if I want to make it fail only
once?

Thanks,
Carl



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-test-redeliver-messages-tp5799456.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to test redeliver messages?

Posted by carlphilipp <cp...@gmail.com>.
Thanks Claus, it worked well!



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-test-redeliver-messages-tp5799456p5799666.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to test redeliver messages?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can weave and replace with a mock, and then on the mock endpoint
you can specify that it should throw an exception on the first
message, or the N'th message, with the whenExchangeReceive method.

The Camel in Action book covers this in the testing chapter.



On Sat, May 13, 2017 at 8:11 PM, carlphilipp <cp...@gmail.com> wrote:
> Hello everybody,
>
> I would like to make sure my redeliver logic is working. I do not find any
> feature to do that.
> For example, is there anyway to do:
>
> weaveById("ws-call").replace().throwException(new RuntimeException());
>
> This will throw the exception anytime, what if I want to make it fail only
> once?
>
> Thanks,
> Carl
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-test-redeliver-messages-tp5799456.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: How to test redeliver messages?

Posted by giannis_k <ik...@yahoo.gr>.
Hey Carl,

you can define a custom processor to throw an exception whenever you want:

weaveById("ws-call").replace().processor(new Processor {
    
    @Override
    void process(Exchange e) {
        // Some custom logic in here to throw an exception
    }
}); 



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-test-redeliver-messages-tp5799456p5799480.html
Sent from the Camel - Users mailing list archive at Nabble.com.