You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jamalissimo <ro...@gmail.com> on 2014/01/07 06:58:50 UTC
ActiveMQ processing
Hello guys, I am quite new to whole activeMQ thing, but here is the thing. I
have this route which works ok, but my problem is that I have to wait till
"activemq:queue:users.add" route ends and then get result. I want it to work
in background. I simply need to send request to add user and immediately
receive response that it was added in the queue and is being processed
from("direct:addUsers")
.setHeader("group", method("usersBean", "getGroup"))
.to("activemq:queue:users.add")
.to("bean:response?method=getResponse");
I am using Karaf 2.3.1 and Camel 2.11.0
Thanks for help
-Roman
--
View this message in context: http://camel.465427.n5.nabble.com/ActiveMQ-processing-tp5745652.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ActiveMQ processing
Posted by "kraythe ." <kr...@gmail.com>.
Write two routes: one that writes to a JMS queue and one that picks up data
off the queue and processes it:
from("direct:input").to("activemq:queue:inbox");
from("activemq:queue:inbox"). <other processing here> .
to("activemq:queue:results");
This manner you can shove data in as fast as you want and even have
concurrent consumers of the inbox queue that will parallel process the
input data. At the same time you can have your results queue. You can then,
if you wish, process that queue for reporting and so on.
*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*
On Tue, Jan 7, 2014 at 7:18 AM, jamalissimo <ro...@gmail.com> wrote:
> Hi hekonsek,
>
> I know that I will get the result when the request is solved in queue, but
> for example, when I am processing big amount of data, I don't want to wait
> 20 seconds. I can use "to("direct:foo")" for this purpose. I just want add
> the requests to the queue and return result right away(like processing data
> in progress), and all work would be done in background. Hope you know what
> I
> mean :-)
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/ActiveMQ-processing-tp5745652p5745676.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: ActiveMQ processing
Posted by Henryk Konsek <he...@gmail.com>.
> I know that I will get the result when the request is solved in queue, but
> for example, when I am processing big amount of data, I don't want to wait
> 20 seconds.
You won't wait. :) You will submit task to the queue and immediately
return control to the "response" bean at the end of the route.
In the meantime another route will consume orders from the queue and
create users in the background:
from("activemq:queue:users.add").
bean(SlowBeanAddingUsers.class).
to("activemq:queue:users.done");
from("activemq:queue:users.done").to("mock:notifyMeWhenUserHasBeenCreated");
You're on the right track with your example. :)
Cheers.
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: ActiveMQ processing
Posted by jamalissimo <ro...@gmail.com>.
Hi hekonsek,
I know that I will get the result when the request is solved in queue, but
for example, when I am processing big amount of data, I don't want to wait
20 seconds. I can use "to("direct:foo")" for this purpose. I just want add
the requests to the queue and return result right away(like processing data
in progress), and all work would be done in background. Hope you know what I
mean :-)
--
View this message in context: http://camel.465427.n5.nabble.com/ActiveMQ-processing-tp5745652p5745676.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: ActiveMQ processing
Posted by Henryk Konsek <he...@gmail.com>.
> If you are not using InOnly pattern
If you *are* using InOnly pattern
Re: ActiveMQ processing
Posted by Henryk Konsek <he...@gmail.com>.
Hi Roman,
> I simply need to send request to add user and immediately
> receive response that it was added in the queue and is being processed
Your route seems to do it :) . If you are not using InOnly pattern
(just as you do), Camel will proceed to bean:response as soon as the
JMS message will be sent to the queue.
Why do you think it is not working as you expected?
Cheers.
--
Henryk Konsek
http://henryk-konsek.blogspot.com