You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Krystian <k....@gmail.com> on 2010/11/06 00:59:53 UTC
Re: Delayer and asyncDelayed - how to delay asynchronously
I've tried doing something I did with 1.x version of camel, calling a method
to figure out the delay.
I can't get that to work though:
<bean id="delayer" class="my.DelayerBean"/>
<camel:camelContext id="camel5">
<!--<camel:routeBuilder ref="redevTest" />-->
<camel:route>
<camel:from uri="activemq:redeliveryQueue"/>
<camel:delay>
<camel:method ref="delayer" method="sendAtTime"/>
</camel:delay>
<camel:to uri="activemq:testQueue"/>
</camel:route>
</camel:camelContext>
package my
class DelayerBean {
public long sendAtTime() {
return System.currentTimeMillis() + 10000
}
}
There's no delay and if I put a breakpoint in the method I will never get
there. It's not called.
I've tried changing the <method> to:
<camel:method bean="delayer" method="sendAtTime"/>
<camel:method bean="my.DelayerBean" method="sendAtTime"/>
same thing, function is never called.
Any tips?
--
View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3252679.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Krystian <k....@gmail.com>.
Ahh..
I moved to a RouteBuilder because of this ;)
Thanks!
--
View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3253391.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Ah in Spring XML you gotta inline the nodes to be delayed.
Notice how to to is inside the delay tag.
There is a ticket in JIRA to improve this in Camel 3.0, as we got 3
DSL which acts like this, but its not intuitive
- delay
- throttle
- threads
Which requires the "stuff" to be inside its tag.
<camel:route>
<camel:from uri="activemq:redeliveryQueue"/>
<camel:delay>
<camel:method ref="delayer" method="sendAtTime"/>
<camel:to uri="activemq:testQueue"/>
</camel:delay>
</camel:route>
On Sat, Nov 6, 2010 at 12:59 AM, Krystian <k....@gmail.com> wrote:
>
> I've tried doing something I did with 1.x version of camel, calling a method
> to figure out the delay.
> I can't get that to work though:
>
>
> <bean id="delayer" class="my.DelayerBean"/>
>
> <camel:camelContext id="camel5">
> <!--<camel:routeBuilder ref="redevTest" />-->
> <camel:route>
> <camel:from uri="activemq:redeliveryQueue"/>
> <camel:delay>
> <camel:method ref="delayer" method="sendAtTime"/>
> </camel:delay>
> <camel:to uri="activemq:testQueue"/>
> </camel:route>
> </camel:camelContext>
>
>
> package my
>
> class DelayerBean {
> public long sendAtTime() {
> return System.currentTimeMillis() + 10000
> }
> }
>
>
> There's no delay and if I put a breakpoint in the method I will never get
> there. It's not called.
>
> I've tried changing the <method> to:
> <camel:method bean="delayer" method="sendAtTime"/>
> <camel:method bean="my.DelayerBean" method="sendAtTime"/>
>
> same thing, function is never called.
>
> Any tips?
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3252679.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
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Krystian <k....@gmail.com>.
Nah, it works quite well.
Here's my bean:
import org.apache.camel.Header
class DelayerBean {
private static final long DELAY = 1000
public DelayerBean() {}
public long sendAtTime(@Header("JMSTimestamp") long messageTimestamp,
@Header("JMSMessageId") String msgId, @Header("msgNo")int id) {
long currentTime = System.currentTimeMillis()
long toBeDelayed = (currentTime - messageTimestamp) > DELAY ? 0 :
DELAY - (currentTime - messageTimestamp)
toBeDelayed = toBeDelayed < 0 ? 0 : toBeDelayed
println("DELAY: MessageId:$id messageTimestamp:$messageTimestamp
current:$currentTime diff:${currentTime - messageTimestamp}
toBeDelayed:$toBeDelayed")
return toBeDelayed
}
public String test() {
println("self test")
return "bean working"
}
}
Yes.. I know. println ;) It's just a proof of concept project.
--
View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3253170.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I think the delayer in Camel 2.x is a bit different than 1.x which
kinda magically could use the timestuff from the JMS message. (eg it
was tied a bit into the JMS world).
So you may have to "compute" the delay a bit differently in 2.x than 1.x.
On Sat, Nov 6, 2010 at 11:45 AM, Krystian <k....@gmail.com> wrote:
>
> Hi,
>
> Thanks for the answer, however I got there without using concurrent
> consumers.
> 2 years ago I was doing something ... well ... similar in a way.
> Anyway... I am using a method call during delay [1] and in my bean I check
> the difference between current time and timestamp on the message and delay
> for as long as it takes to reach the DELAY I want it to be.
> Since all messages are to be delayed by the same amount of time, there's no
> way I will get a message which is to be delayed for longer than next message
> in the line.
> Worst case scenario:
> I get two messages at the same time.
> First one is delayed by DELAY, next one is delayed by 0.
>
> Thanks,
> Krystian
>
> [1]
> from("activemq:redeliveryQueue").delay().expression(bean(DelayerBean.class,
> "sendAtTime")).to("activemq:testQueue")
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3252973.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
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Krystian <k....@gmail.com>.
Hi,
Thanks for the answer, however I got there without using concurrent
consumers.
2 years ago I was doing something ... well ... similar in a way.
Anyway... I am using a method call during delay [1] and in my bean I check
the difference between current time and timestamp on the message and delay
for as long as it takes to reach the DELAY I want it to be.
Since all messages are to be delayed by the same amount of time, there's no
way I will get a message which is to be delayed for longer than next message
in the line.
Worst case scenario:
I get two messages at the same time.
First one is delayed by DELAY, next one is delayed by 0.
Thanks,
Krystian
[1]
from("activemq:redeliveryQueue").delay().expression(bean(DelayerBean.class,
"sendAtTime")).to("activemq:testQueue")
--
View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3252973.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel activeMQ pooling frequency
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I assume you mean Camel is consuming from a message queue, eg
Something a like a route
<route>
<from uri="activemq:queue:foo"/>
...
</route>
Camel uses Spring DMLC for consuming messages.
See the receive timeout, which influences how often DMLC will re-poll
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jms/listener/AbstractPollingMessageListenerContainer.html#setReceiveTimeout(long)
You can adjust this value, using the receiveTimeout option on the endpoint
http://camel.apache.org/jms
On Tue, Apr 3, 2012 at 2:33 PM, mihinot <mi...@gmail.com> wrote:
> Hello,
>
> I'm a new camel user and i'm actually working on a project integrating this
> tech. With my team, we've recently deployed a web application wich load data
> in JMS queues on camel activeMQ. I've seen that camel is pooling non-stop
> (everytime) for verifying the JMS queues content and I'd like to know how I
> could define a frequency for camel activeMQ pooling.
>
> I hope i've been clear in my explanations
>
> Thax !
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p5614975.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
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/
camel activeMQ pooling frequency
Posted by mihinot <mi...@gmail.com>.
Hello,
I'm a new camel user and i'm actually working on a project integrating this
tech. With my team, we've recently deployed a web application wich load data
in JMS queues on camel activeMQ. I've seen that camel is pooling non-stop
(everytime) for verifying the JMS queues content and I'd like to know how I
could define a frequency for camel activeMQ pooling.
I hope i've been clear in my explanations
Thax !
--
View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p5614975.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Delayer and asyncDelayed - how to delay asynchronously
Posted by Claus Ibsen <cl...@gmail.com>.
You need to use the concurrent consumers option on the JMS endpoint to
process message concurrently which is what you want
http://camel.apache.org/jms
On Sat, Nov 6, 2010 at 12:59 AM, Krystian <k....@gmail.com> wrote:
>
> I've tried doing something I did with 1.x version of camel, calling a method
> to figure out the delay.
> I can't get that to work though:
>
>
> <bean id="delayer" class="my.DelayerBean"/>
>
> <camel:camelContext id="camel5">
> <!--<camel:routeBuilder ref="redevTest" />-->
> <camel:route>
> <camel:from uri="activemq:redeliveryQueue"/>
> <camel:delay>
> <camel:method ref="delayer" method="sendAtTime"/>
> </camel:delay>
> <camel:to uri="activemq:testQueue"/>
> </camel:route>
> </camel:camelContext>
>
>
> package my
>
> class DelayerBean {
> public long sendAtTime() {
> return System.currentTimeMillis() + 10000
> }
> }
>
>
> There's no delay and if I put a breakpoint in the method I will never get
> there. It's not called.
>
> I've tried changing the <method> to:
> <camel:method bean="delayer" method="sendAtTime"/>
> <camel:method bean="my.DelayerBean" method="sendAtTime"/>
>
> same thing, function is never called.
>
> Any tips?
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Delayer-and-asyncDelayed-how-to-delay-asynchronously-tp3252456p3252679.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
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/