-
1. Re: Delayed Queue in Switchyard
jorgemoralespou_2 Jun 16, 2014 8:19 AM (in response to vinodhvp)Hi,
I think JMS spec doesn't support for delayed messages, although some implementations does, like HornetQ and ActiveMQ, but depending on which JMS broker you are using details might be slightly different.
Check this article:
http://java.dzone.com/articles/sending-delayed-jms-messages
If you use HornetQ, just set a header for the message
msg.setLongProperty(“JMS_JBOSS_SCHEDULED_DELIVERY”, now + delay);
Hope it helps.
Otherwise, read the specific broker documentation.
Of course, you can do it in various alternative ways, using quartz endpoint to trigger consumption.
Cheers,
-
2. Re: Delayed Queue in Switchyard
vinodhvp Jun 28, 2014 12:58 AM (in response to jorgemoralespou_2)Hi Jorge,
Thanks a lot for the reply.
We are using switchyard and sets the properties through switchyard diagram.
I tried to set the property "JMS_JBOSS_SCHEDULED_DELIVERY” through switchyard for "JMS", but the system doesn't recognize the property.
Hence I tried the following way.I am not using JMS anymore.
from("switchyard://MyOwnCamelRoute")
.delay(10000).asyncDelayed()
.log("Received message for 'MyOwnCamelRoute' : ${body}")
.to("jms:MyQueue?connectionFactory=java:/ConnectionFactory")
;
This is working properly.
The delay happens correct, but the call is not asynchronous.
Even though I set the "asyncDelayed, the control comes back only after the delay.
Am I doing anything wrong here?What steps needs to be done for making this an asynchronous call?
Thanks
Anand
-
3. Re: Delayed Queue in Switchyard
jorgemoralespou_2 Jun 30, 2014 4:34 AM (in response to vinodhvp)Hi Anand,
Since I'm not a Camel expert, I can not be of any help here.
Have you tried the pattern in Camel standalone in a JUnit? This is to sort if there is a problem with the route, or with SwitchYard implementation. Then, depending on the source of the problem, if it is Camel related, I recommend you asking in the camel community, or camel irc as there is a very active community of camel practitioners out there.
Cheers,
-
4. Re: Delayed Queue in Switchyard
vinodhvp Jan 12, 2016 11:33 AM (in response to jorgemoralespou_2)Hi,
Found a solution to this.
I am adding this here if it can be helpful for others.
Added a contextMapper class in switchyard something like this.
public class MyMapper extends org.switchyard.component.camel.common.composer.CamelContextMapper{
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.switchyard.Context;
import org.switchyard.component.camel.common.composer.CamelBindingData;
public class MyMapper extends org.switchyard.component.camel.common.composer.CamelContextMapper{
@Override
public void mapTo(Context context, CamelBindingData target) throws Exception{
Message message = target.getMessage();
super.mapTo(context, target);
long time = System.currentTimeMillis();
time += 20000;//add the time delay here
message.setHeader("_HQ_SCHED_DELIVERY", time);
}
}