You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mikeycmccarthy <Mi...@gmail.com> on 2012/02/16 12:18:27 UTC

Checking a message is back on the queue

I'm trying to write an integration test where some error condition happens, a
retry policy kicks in, and eventually the message ends up back on the queue.
I'm using the CamelSpringTestSupport to do this. 

The thing I want to throw an exception is a bean, and as I understand you
can't swap these out using advice, I simply wire in a stub one in my spring
config. All good so far.

In semi psuedo-code the test looks something like this:

    @Produce(uri = CONSUMER_ENDPOINT)
    protected ProducerTemplate template;

test {
template.sendBodyAndHeader(xyz);
Object message consumer.receiveBodyNoWait(CONSUMER_ENDPOINT, Object.class);
}

What I'm trying to achieve is send the message then check the queue
afterwards. But Camel is telling me that I'm trying to put another consumer
on the same endpoint. How would you normally go about testing such a
scenario?

Thanks,
Michael


--
View this message in context: http://camel.465427.n5.nabble.com/Checking-a-message-is-back-on-the-queue-tp5489222p5489222.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Checking a message is back on the queue

Posted by Mikeycmccarthy <Mi...@gmail.com>.
This worked a treat, thanks Claus. I created a stopAllRoutes() method, shut
down everything, and asserted the message body to make sure it did match
what I sent. Not sure if this is a valid helper method to go up into
CamelTestSupport.

--
View this message in context: http://camel.465427.n5.nabble.com/Checking-a-message-is-back-on-the-queue-tp5489222p5502081.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Checking a message is back on the queue

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Feb 16, 2012 at 12:18 PM, Mikeycmccarthy
<Mi...@gmail.com> wrote:
> I'm trying to write an integration test where some error condition happens, a
> retry policy kicks in, and eventually the message ends up back on the queue.
> I'm using the CamelSpringTestSupport to do this.
>
> The thing I want to throw an exception is a bean, and as I understand you
> can't swap these out using advice, I simply wire in a stub one in my spring
> config. All good so far.
>
> In semi psuedo-code the test looks something like this:
>
>    @Produce(uri = CONSUMER_ENDPOINT)
>    protected ProducerTemplate template;
>
> test {
> template.sendBodyAndHeader(xyz);
> Object message consumer.receiveBodyNoWait(CONSUMER_ENDPOINT, Object.class);
> }
>
> What I'm trying to achieve is send the message then check the queue
> afterwards. But Camel is telling me that I'm trying to put another consumer
> on the same endpoint. How would you normally go about testing such a
> scenario?
>

You can stop the route, and then check the AMQ afterwards.


> Thanks,
> Michael
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Checking-a-message-is-back-on-the-queue-tp5489222p5489222.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/