|
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 |
|
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 <[hidden email]> 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. |
|
This post has NOT been accepted by the mailing list yet.
I am having a similar problem, I am using ActiveMQ for JMS resource from which I consume messages,
My acknowlgementMode is CLIENT_ACK How do I verify in the UnitTest that the message actually have being DE QUEUED from JMS resource.? |
|
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! |
|
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 <[hidden email]> 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. |
|
In reply to this post by gilboy
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 <[hidden email]> 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. > |
| Powered by Nabble | Edit this page |
