2008/5/9 Krystian Szczesny <[EMAIL PROTECTED]>:
>
>
>
> James.Strachan wrote:
>>
>> 2008/5/9 Krystian Szczesny <[EMAIL PROTECTED]>:
>>>
>>> Hi,
>>>
>>>
>>> Before, when delaying single messages I've used for example
>>> delayer(3000)
>>> and it worked flawlessly.
>>> Now I need to delay a sequence of messages, so when I send 5 messages,
>>> the
>>> first should be delayed by 3000, second by 6000 etc...
>>>
>>> Is there any way I could do that with Camel?
>>
>> You just need to use an expression for the time that the message is to
>> be sent at. So you could do something like...
>>
>> from("activemq:foo").delay().method("someBean",
>> "sendAtTime").to("activemq:bar");
>>
>> then the bean would look like this...
>>
>> public class SomeBean {
>> public long sendAtTime(@Header("MyDelayHeader") long delay) {
>> if (delay <= 0) delay = 3000;
>> return System.currentTimeMillis() + delay;
>> }
>> }
>>
>> which would look for the MyDelayHeader on the message and use that as the
>> delay.
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://open.iona.com
>>
>>
>
> I don't think there is .delay() there.
> It's delayer() at least in 1.3.
Yeah sorry - I was just typing pseudocode; I don't yet have IntelliJ
code completion in my gmail client :)
> And second thing... The code you have given, will only delay for 3000 not
> mater what.
> What I need is to send 9 messages and delay them for:
> 3000, 6000, 9000
So the delay used on each message can be calculated dynamically using
any Expression you like. So you could pull some value or header from
each message and use that to determine the delay/time to send it.
e.g. you could just put the time to send it on each message as a
header then let the delayer use that.
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://open.iona.com