Quantcast

How to test redeliver messages?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to test redeliver messages?

carlphilipp
This post was updated on .
Hello everybody,

I would like to make sure my redeliver logic is working. I do not find any feature to do that.
For example, I can 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to test redeliver messages?

giannis_k
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
    }
});
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to test redeliver messages?

Claus Ibsen-2
In reply to this post by carlphilipp
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 <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to test redeliver messages?

carlphilipp
Thanks Claus, it worked well!
Loading...