You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Mick Knutson <mk...@baselogic.com> on 2008/10/02 02:55:53 UTC
How to unit test timeToLive messages
I am trying to send a message to a timeout queue:
activemq:queue:channel/command/timeout?*timeToLive=40000*
but what I want is for those messages to timeout after 4000 if they have not
been consumed, and send that message to a DeadLetterChannel.
How can I do this, and how can I unit test this?
--
---
Thank You…
Mick Knutson
BASE Logic, inc.
(415) 354-4215
Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
Re: How to unit test timeToLive messages
Posted by Mick Knutson <mk...@baselogic.com>.
I am trying to test with:
*@Parameters({"startEndpointUri", "successEndpointUri",
"tapEndpointUri", "errorEndpointUri", "messageInputBody"})
public void testReceiveValidStatusUpdateTimedout(String
startEndpointUri,
String
successEndpointUri,
String tapEndpointUri,
String
errorEndpointUri,
String messageInputBody
)
throws Exception {
MockEndpoint mockSuccessEndpoint =
getMockEndpoint(successEndpointUri);
MockEndpoint mockFailureEndpoint =
getMockEndpoint(errorEndpointUri);
mockFailureEndpoint.expectedMessageCount(0);
mockSuccessEndpoint.expectedMessageCount(1);
try {
// setup RouteBuilder...
// Create and Send message to input queue
camelContext.addRoutes(
createRoute(startEndpointUri,
statusUpdateProcessor,
tapEndpointUri,
successEndpointUri,
errorEndpointUri
)
);
// Create and Send message to input queue
producerTemplate.sendBodyAndHeader(startEndpointUri,
messageInputBody, Constants.COMMAND_TYPE, Constants.JOB_STATUS);
wait(2000); // my ttl is 1000
Assert.fail("Should have thrown a ExchangeTimedOutException");
} catch (RuntimeCamelException e) {
assertIsInstanceOf(e, ExchangeTimedOutException.class);
}
testMocksAreValid();
MockEndpoint.assertIsSatisfied(mockSuccessEndpoint,
/*mockTapEndpoint, */mockFailureEndpoint);
}*
But I this error for my wait():
*<![CDATA[java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
at com.servepath.chan*
gerequest.StatusUpdateTest.testReceiveValidStatusUpdateTimedout(StatusUpdateTest.java:125)
I am trying to send a message to my *timoutQueue*, then if nobody picks up
the messages in xx seconds, send that message to the *deadLetterChannel*.
On Thu, Oct 2, 2008 at 2:48 AM, James Strachan <ja...@gmail.com>wrote:
> 2008/10/2 Mick Knutson <mk...@baselogic.com>:
> > I am trying to send a message to a timeout queue:
> >
> > activemq:queue:channel/command/timeout?*timeToLive=40000*
> >
> > but what I want is for those messages to timeout after 4000 if they have
> not
> > been consumed, and send that message to a DeadLetterChannel.
> >
> > How can I do this, and how can I unit test this?
>
> The easiest way to solve this is to use the JMS providers Dead Letter
> handling of expired messages; so subscribe to the Dead Letter topic
> for expired messages on ActiveMQ.
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://open.iona.com
>
--
---
Thank You…
Mick Knutson
BASE Logic, inc.
(415) 354-4215
Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
Re: How to unit test timeToLive messages
Posted by James Strachan <ja...@gmail.com>.
2008/10/2 Mick Knutson <mk...@baselogic.com>:
> I am trying to send a message to a timeout queue:
>
> activemq:queue:channel/command/timeout?*timeToLive=40000*
>
> but what I want is for those messages to timeout after 4000 if they have not
> been consumed, and send that message to a DeadLetterChannel.
>
> How can I do this, and how can I unit test this?
The easiest way to solve this is to use the JMS providers Dead Letter
handling of expired messages; so subscribe to the Dead Letter topic
for expired messages on ActiveMQ.
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com
RE: How to unit test timeToLive messages
Posted by Claus Ibsen <ci...@silverbullet.dk>.
Hi
A kind of similar test is this unit test:
JmsRouteTimeoutTest
In the camel-jms component. You can find the source from:
http://svn.apache.org/viewvc/activemq/camel/trunk/
Could you take a look at this one for starters?
Med venlig hilsen
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk
-----Original Message-----
From: Mick Knutson [mailto:mknutson@baselogic.com]
Sent: 2. oktober 2008 02:56
To: Camel
Subject: How to unit test timeToLive messages
I am trying to send a message to a timeout queue:
activemq:queue:channel/command/timeout?*timeToLive=40000*
but what I want is for those messages to timeout after 4000 if they have not
been consumed, and send that message to a DeadLetterChannel.
How can I do this, and how can I unit test this?
--
---
Thank You...
Mick Knutson
BASE Logic, inc.
(415) 354-4215
Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com