You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by gilboy <jo...@gmail.com> on 2012/07/02 18:15:01 UTC

Testing a Route which de-queues message from Topic in CLIENT_ACKNOWLEDGE mode

Hi 

I have a route where I consume a message from a JMS topic and do some
processing of the message.

I have the JMS Ack mode set to: CLIENT_ACKNOWLEDGE mode

If the route successfully completes the message is dequeued. I want to
verify that this takes place, i.e. message gets dequeued. Does the camel
junit extensions support verifying that the message has been de-queued?

Thanks


--
View this message in context: http://camel.465427.n5.nabble.com/Testing-a-Route-which-de-queues-message-from-Topic-in-CLIENT-ACKNOWLEDGE-mode-tp5715361.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing a Route which de-queues message from Topic in CLIENT_ACKNOWLEDGE mode

Posted by Pontus Ullgren <ul...@gmail.com>.
Hi,

You can get the statistics from the BorkerService object.
To be honest I have never tested this with topics but for a queue the
calls are like this.

--------------
ActiveMQDestination queryDest =
                        ActiveMQDestination.createDestination("myQueue",
                                        ActiveMQDestination.QUEUE_TYPE);

Destination dest = broker.getDestination(queryDest);
DestinationStatistics stats = dest.getDestinationStatistics();

assertEquals(0, stats.getMessages().getCount());
assertEquals(1, stats.getEnqueues().getCount());
assertEquals(1, stats.getDequeues().getCount());
--------------
// Pontus


On Thu, Jul 5, 2012 at 4:24 PM, gilboy <jo...@gmail.com> wrote:
> Hi Folks
>
> It was also unclear to me how to ensure that the message was de-queued or
> not.
>
> Ideally, after starting up the broker service in my junit test I would like
> to put a message on to the queue and then verify I have successfully
> de-queued the message at the end of my testcase by ensuring the size of the
> queue is *0*.
>
> Again, when testing a flow in my route which should *not *dequeue the
> message I would like to put a message on to the queue and then verify the
> message has not been de-queued by verifying that the size of the queue is
> *1*
>
> However, I cannot figure out how to determine the size of the queue.
>
> Thanks!
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-a-Route-which-de-queues-message-from-Topic-in-CLIENT-ACKNOWLEDGE-mode-tp5715361p5715553.html
> Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing a Route which de-queues message from Topic in CLIENT_ACKNOWLEDGE mode

Posted by Christian Müller <ch...@gmail.com>.
You can use the consumer template to consume one message from the queue and
check the received exchange is not null.

Best,
Christian

On Thu, Jul 5, 2012 at 4:24 PM, gilboy <jo...@gmail.com> wrote:

> Hi Folks
>
> It was also unclear to me how to ensure that the message was de-queued or
> not.
>
> Ideally, after starting up the broker service in my junit test I would like
> to put a message on to the queue and then verify I have successfully
> de-queued the message at the end of my testcase by ensuring the size of the
> queue is *0*.
>
> Again, when testing a flow in my route which should *not *dequeue the
> message I would like to put a message on to the queue and then verify the
> message has not been de-queued by verifying that the size of the queue is
> *1*
>
> However, I cannot figure out how to determine the size of the queue.
>
> Thanks!
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Testing-a-Route-which-de-queues-message-from-Topic-in-CLIENT-ACKNOWLEDGE-mode-tp5715361p5715553.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Testing a Route which de-queues message from Topic in CLIENT_ACKNOWLEDGE mode

Posted by gilboy <jo...@gmail.com>.
Hi Folks

It was also unclear to me how to ensure that the message was de-queued or
not. 

Ideally, after starting up the broker service in my junit test I would like
to put a message on to the queue and then verify I have successfully
de-queued the message at the end of my testcase by ensuring the size of the
queue is *0*.

Again, when testing a flow in my route which should *not *dequeue the
message I would like to put a message on to the queue and then verify the
message has not been de-queued by verifying that the size of the queue is
*1*

However, I cannot figure out how to determine the size of the queue.

Thanks!

--
View this message in context: http://camel.465427.n5.nabble.com/Testing-a-Route-which-de-queues-message-from-Topic-in-CLIENT-ACKNOWLEDGE-mode-tp5715361p5715553.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing a Route which de-queues message from Topic in CLIENT_ACKNOWLEDGE mode

Posted by Pontus Ullgren <ul...@gmail.com>.
Hello,

You should be able to do this by running a embedded broker in you
integration unit tests.
After the test has completed you can verify that there are no
remaining messages on the JMS queue.

For more info see http://activemq.apache.org/how-to-unit-test-jms-code.html
and there is also a nice webinar on fusesource.com
( http://fusesource.com/resources/video-archived-webinars/ ) titled
"Are your Apache Camel Routes Ready for Production" where there are
some slides that cover the topic of having a embedded broker.

Best regards
Pontus Ullgren

On Mon, Jul 2, 2012 at 6:15 PM, gilboy <jo...@gmail.com> wrote:
> Hi
>
> I have a route where I consume a message from a JMS topic and do some
> processing of the message.
>
> I have the JMS Ack mode set to: CLIENT_ACKNOWLEDGE mode
>
> If the route successfully completes the message is dequeued. I want to
> verify that this takes place, i.e. message gets dequeued. Does the camel
> junit extensions support verifying that the message has been de-queued?
>
> Thanks
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-a-Route-which-de-queues-message-from-Topic-in-CLIENT-ACKNOWLEDGE-mode-tp5715361.html
> Sent from the Camel - Users mailing list archive at Nabble.com.