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/15 15:34:26 UTC
How to get configure concurrent consumers for POJO with @Consume
Hi,
I've created a POJO with @Consume and it works great. However I have to be
able to have more than one consumer listening on the queue.
How can I get more of them?
I can only hope it does not mean I will have to create 20 <bean/> entries
for 20 concurrent consumers ;)
Thanks,
Krystian
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-get-configure-concurrent-consumers-for-POJO-with-Consume-tp3265743p3265743.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to get configure concurrent consumers for POJO with @Consume
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Nov 15, 2010 at 3:34 PM, Krystian <k....@gmail.com> wrote:
>
> Hi,
>
> I've created a POJO with @Consume and it works great. However I have to be
> able to have more than one consumer listening on the queue.
> How can I get more of them?
> I can only hope it does not mean I will have to create 20 <bean/> entries
> for 20 concurrent consumers ;)
>
What queue are you talking about?
If its a JMS queue, then just add option concurrentConsumer=10 in the
endpoint uri
http://camel.apache.org/jms
> Thanks,
> Krystian
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-get-configure-concurrent-consumers-for-POJO-with-Consume-tp3265743p3265743.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: How to get configure concurrent consumers for POJO with
@Consume
Posted by Krystian <k....@gmail.com>.
Sorry Claus...
I screwed up by using the same producer all the time, which was waiting for
response before making next call ;)
My bad
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-get-configure-concurrent-consumers-for-POJO-with-Consume-tp3265743p3265831.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to get configure concurrent consumers for POJO with @Consume
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Nov 15, 2010 at 4:10 PM, Krystian <k....@gmail.com> wrote:
>
> Hmmm
>
> It seems not to work - adding concurrentConsumers option. But it's probably
> because I am adding it in wrong place.
> I don't have any routes configured.
> It's a very simple test code, two pojos:
>
> class PojoProducer {
> @Produce(uri="activemq:entryQueue")
> ProducerTemplate producer
>
> public void send(Map what) {
> println("RESPONSE: ${producer.sendBody("activemq:entryQueue",
> ExchangePattern.InOut, what)}")
> }
> }
>
>
> class PojoConsumer {
> @Consume(uri="activemq:entryQueue?concurrentConsumers=10")
> public Map consume(Map body) {
> println("READ: $body")
> Thread.sleep(100)
> return ["response":body["request"]]
> }
> }
>
> [yeah, it's in groovy].
>
> So i basically call the producer.send 10 times. However everything seems to
> be done synchronously, as this is the system.out I am getting:
> READ: [request:0]
> RESPONSE: [response:0]
> READ: [request:1]
> RESPONSE: [response:1]
> READ: [request:2]
> RESPONSE: [response:2]
> READ: [request:3]
> RESPONSE: [response:3]
> [...]
>
> I've added ?concurrentConsumers=10 to both, Consume and Produce annotations
> but this didn't change a thing. Do I have to create a route in order to make
> this work?
Hmm could you try sleeping 2 sec to be absolutely sure.
You may have hit a corner case here. If its a route then it definitely works.
The concurrentConsumer options is for the Spring DMLC so it ought not
to affect Camel when using @Consume or from a route.
Anyway dig a bit more and report back.
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-get-configure-concurrent-consumers-for-POJO-with-Consume-tp3265743p3265797.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: How to get configure concurrent consumers for POJO with
@Consume
Posted by Krystian <k....@gmail.com>.
Hmmm
It seems not to work - adding concurrentConsumers option. But it's probably
because I am adding it in wrong place.
I don't have any routes configured.
It's a very simple test code, two pojos:
class PojoProducer {
@Produce(uri="activemq:entryQueue")
ProducerTemplate producer
public void send(Map what) {
println("RESPONSE: ${producer.sendBody("activemq:entryQueue",
ExchangePattern.InOut, what)}")
}
}
class PojoConsumer {
@Consume(uri="activemq:entryQueue?concurrentConsumers=10")
public Map consume(Map body) {
println("READ: $body")
Thread.sleep(100)
return ["response":body["request"]]
}
}
[yeah, it's in groovy].
So i basically call the producer.send 10 times. However everything seems to
be done synchronously, as this is the system.out I am getting:
READ: [request:0]
RESPONSE: [response:0]
READ: [request:1]
RESPONSE: [response:1]
READ: [request:2]
RESPONSE: [response:2]
READ: [request:3]
RESPONSE: [response:3]
[...]
I've added ?concurrentConsumers=10 to both, Consume and Produce annotations
but this didn't change a thing. Do I have to create a route in order to make
this work?
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-get-configure-concurrent-consumers-for-POJO-with-Consume-tp3265743p3265797.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to get configure concurrent consumers for POJO with @Consume
Posted by Claus Straube <cl...@catify.com>.
Hi,
No, you need not: http://camel.apache.org/competing-consumers.html
In Java DSL something like
from("jms:MyQueue?concurrentConsumers=5").bean(SomeBean.class);
Claus
On 15.11.2010 15:34, Krystian wrote:
> Hi,
>
> I've created a POJO with @Consume and it works great. However I have to be
> able to have more than one consumer listening on the queue.
> How can I get more of them?
> I can only hope it does not mean I will have to create 20<bean/> entries
> for 20 concurrent consumers ;)
>
> Thanks,
> Krystian