You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by salemi <sa...@avaya.com> on 2013/07/10 05:59:57 UTC

Incoming message from the queue need to be send to multiple consumer but keep the ordering

Hi,
I like to implement a mechanism in Camel to receive message from a JMS
queue. Once I have identified the type of message based on the content than
I can forward them  to JavaSpaces. The write to JavaSpaces takes about 3ms
so I need to parallelize the writes. But there is a catch I can't
parallelize the messages without restrictions since there are buckets of
messages that need to be processed in the order they have been received.

Let say for example, we have message types a, b and c. All the messages of
type "a" has to be processed in order and all the messages of type "b" has
to be processed in order and All the messages of type "c" has to be
processed in order. 
Is there a way to consume the messages from the JMS and split them up in to
buckets for a, b and c and send the a, b,c messages in parallel to
JavaSpaces?

<from uri="jms:queue:abc">
  <filter a>
    <to start thread and save to javaspaces>
  <filter b>
    <to start thread and save to javaspaces>
  <filter c>
    <to start thread and save to javaspaces>



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-the-queue-need-to-be-send-to-multiple-consumer-but-keep-the-ordering-tp5735406.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by gquintana <ge...@gmail.com>.
You could have one (and only one) JMS message listener for each kind of
message and use JMS message selector to let one thread select some kind of
messages while leaving other ones. Each listener thread will consume ordered
messages of one kind, each listener will separately from others.



--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735437.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by Raul Kripalani <ra...@evosent.com>.
On Mon, Jul 15, 2013 at 6:42 PM, salemi <sa...@avaya.com> wrote:

> I am not sure if I can use concurrent consumer option since I have to keep
> the order of messgaes for the buckets.
>

Message groups are meant specially for this scenario. A group is assign to
at most 1 consumer at a time. Therefore, until the consumer is not freed
from its current task, it will not process the next message.

I like your idea to have a route that calculates the Group header but doing
> that is it not going to be the bottleneck for the processing. I have to run
> at least 1000 messages per second trough camel.


No, because apart from being multithreaded, the route is asynchronous and
it simply pushes a message onto another queue. It doesn't wait for the
JavaSpaces processing to finish.

How can you grab 100 messages at the time from JMS in a route?


camel-jms / camel-activemq are based on Spring JMS which AFAIK doesn't
support JMS message batching. You could try out the camel-sjms (Simple JMS)
component which does support this pattern.

Or else, you could use the Aggregator EIP, but I don't see much value in
this particular scenario.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvkM

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by salemi <sa...@avaya.com>.
Thank you for your respond.
I am not sure if I can use concurrent consumer option since I have to keep
the order of messgaes for the buckets.

I like your idea to have a route that calculates the Group header but doing
that is it not going to be the bottleneck for the processing. I have to run
at least 1000 messages per second trough camel.

How can you grab 100 messages at the time from JMS in a route?

<route>
<from uri="jms:queue:abc?GrabMutlileMessages=100>




-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735682.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by Raul Kripalani <ra...@evosent.com>.
Use the concurrentConsumers option in the JMS consumer to start multiple
receiving threads.

Make sure to use the transacted mode to leverage broker-side redeliveries.

Like Claus said above, use JMS Message Groups to serialize the processing
of messages that share a key. If your producer cannot place the required
JMSXGroupId header, create an intermediate route in Camel that (1) picks up
the raw messages, (2) calculates the "bucketing key" based on payload data,
(3) sets the JMSXGroupId header and (4) publishes the resulting message
onto a different JMS queue, where a different Camel route is listening.

Seda will preserve the transaction as long as it's not an XA transaction.
If your JMS messages are InOnly (no JMSReplyTo header, or replyTo option in
the JMS consumer), set the waitForTaskToComplete option to Always on the
producer. Otherwise, your JMS message will be ACK'ed to the broker before
the JavaSpaces publishing takes place and exceptions will not cause a
rollback.

Hope this helps,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Fri, Jul 12, 2013 at 7:10 PM, salemi <sa...@avaya.com> wrote:

> Yep, I was thinking about this approach as well.
> Using Seda is the transnational integrity preserved?
> Let say the delivery of one message using seda fails, does camel recognize
> it and redeliver it?
>
>
>
>
>
> -----
> Alireza Salemi
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735577.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by salemi <sa...@avaya.com>.
Hi Guys,

I am now exploring the idea of JMS message groups. I was wondering how we
can configure camel properly to support proper routing in a failover
scenario.

In a fail over scenario, I need two camel instances per messages groups. I
my example above we will need two camel instances for a , b and c.

How can I configure camel for each message group so that only one of the two
consumer only consumes messages. Do I need to use selector in the camel
routes as below? My understanding is that ActiveMQ will automatically choose
a JMS consumer as the receiver and if the consumer goes down than it will
pick a different one.

<from uri="jms:queue:abc?selector='MyGroupId=a">
<from uri="jms:queue:abc?selector='MyGroupId=b">
<from uri="jms:queue:abc?selector='MyGroupId=c">



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5736271.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by Raul Kripalani <ra...@evosent.com>.
Hi,

Looks like I got things a bit mixed up with the Synchronization usage in
the File consumer for some reason.

You're right, Spring JMS provides the JmsTransactionManager and we leverage
that in this case instead of reinventing the wheel. So as long as the
endpoints along the route share the same ConnectionFactory and are executed
in the same thread (careful with the async routing engine), Spring takes
care of synchronizing the sends/receives.

BTW - I want to clarify. What I meant with "Seda preserving transactional
integrity" is *not* a general statement, i.e. a transaction governed by a
Transaction Manager existing on the producer side of the Seda queue
(route1) will NOT be propagated to the consumer side (route2), as they are
running in different threads. My reply was in the context of the user's
question:

Using Seda is the transnational integrity preserved?
> Let say the delivery of one message using seda fails, does camel recognize
> it and redeliver it?


If JavaSpaces on route2 throws an exception, then it can be propagated to
route1 such that the JMS transaction will roll back. But a JMS send done in
turn form route2 will not enlist itself in the existing TX.

I hope this clarifies things.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Wed, Jul 17, 2013 at 10:40 AM, gquintana <ge...@gmail.com>wrote:

> Hi Raúl,
>
> In a non XA world, how does this Unit of work concept mix with Spring's
> management of transaction and resources (connections) which are bound to
> thread by the TransactionSynchronizationManager?
>
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735789.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by gquintana <ge...@gmail.com>.
Hi Raúl,

In a non XA world, how does this Unit of work concept mix with Spring's
management of transaction and resources (connections) which are bound to
thread by the TransactionSynchronizationManager?





--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735789.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by Raul Kripalani <ra...@evosent.com>.
On Tue, Jul 16, 2013 at 9:48 AM, gquintana <ge...@gmail.com>wrote:

> Seda breaks transaction propagation since different threads are used. But
> you
> can replace seda by JMS
>

This applies when a Global TransactionManager is in place (e.g. JTA), whose
typical way of synchronizing several atomic TXs is by following the thread
and tracking which TXs are bound to that thread. That's why I specifically
referred to non-XA transactions in my email ;-)

When using local (non-XA) JMS transactions, Camel will use the UnitOfWork
concept along with Synchronizations to commit/rollback the transaction when
the Exchange is done. When using waitForReply=Always, the Exchange won't be
done until the reply is received, and therefore the UoW won't complete
until then.

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by gquintana <ge...@gmail.com>.
Seda breaks transaction propagation since different threads are used. But you
can replace seda by JMS
from("jms:queue:abc")
            .choice()
                .when(simple(body.msg.type).isEqualTo("a"))
                    .to("jms:queue:only_a")
                .when(simple(body.msg.type).isEqualTo("b"))
                    .to("jms:queue:only_b");
from("jms:queue:only_a').to("javaspaces");
from("jms:queue:only_b").to("javaspaces");

// With Message selector and single queue  (if your broker supports it)
from("jms:queue:abc")
            .choice()
                .when(simple(body.msg.type).isEqualTo("a"))
                    .setHeader("MyGroupId",1)
                .when(simple(body.msg.type).isEqualTo("b"))
                    .setHeader("MyGroupId",2)
                .end
            .to("jms:queue:enriched_abc");
from("jms:queue:enriched_abc?selector='MyGroupId=1').to("javaspaces");
from("jms:queue:enriched_abc?selector='MyGroupId=2').to("javaspaces");


// Or with JMSXGroupID (if your broker supports it)
from("jms:queue:abc")
            .choice()
                .when(simple(body.msg.type).isEqualTo("a"))
                    .setHeader("JMSXGroupID","a")
                .when(simple(body.msg.type).isEqualTo("b"))
                    .setHeader("JMSXGroupID","b")
                .end
            .to("jms:queue:enriched_abc");
// Multiple consumers, each one should process a different group
from("jms:queue:enriched_abc?concurrentConsumers=3").to("javaspaces");






--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735705.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by salemi <sa...@avaya.com>.
Yep, I was thinking about this approach as well.  
Using Seda is the transnational integrity preserved? 
Let say the delivery of one message using seda fails, does camel recognize
it and redeliver it?





-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735577.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by gquintana <ge...@gmail.com>.
Then why don't you do something like:


The route from JMS to Seda is monothreaded, but it should be fast enough
(the bottleneck is javaspaces, is it?), then each route from Seda to
Javaspaces can work in parallel.



--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735487.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by salemi <sa...@avaya.com>.
Thank you for the responds. 
The problem I have is that I don't have any control of producer and I can't
ask the producer to put information in the header of the message in order to
use the grouping of ActiveMQ.



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735473.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by salemi <sa...@avaya.com>.
Hi,

I am trying to use the message groups and I am getting the following error.
What am I doing wrong.
Exception in thread "main" 2013-08-08 13:01:20,904 [Thread-0       ] INFO 
MainSupport$HangupInterceptor  - Received hang up - stopping the main
instance.
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToStartRouteException: Failed to start route
operationalreceive2 because of Multiple consumers for the same endpoint is
not allowed: Endpoint[jms://queue:cc]
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1280)

The route is as followed
    	<route id="operationalsend"
shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="false">
    		<from
uri="file:target/classes?fileName=operational_msgs&amp;noop=true&amp;idempotent=false"/>
			<log message="Processing big file: ${header.CamelFileName}"/>
			<delay>
            	<constant>20000</constant>
            </delay>
			<split streaming="true">
				<tokenize token="\n"/>
				<unmarshal ref="ccisJSON"/>
				<process ref="jmsMessageGroupProcessor"/> 
				<marshal ref="ccisJSON"/>
				<to uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
			</split>
			<log message="Done processing big file: ${header.CamelFileName}"/>
			<process ref="restartPuRouteProcessor"/>
			<delay>
                <constant>5000</constant>
            </delay>
    	</route>
        <route id="operationalreceive1"
shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
             <from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
                            <process ref="jmsMessageGroupProcessor"/>
             <log message="${header.JMSXGroupID}"/>
        </route>    	
        <route id="operationalreceive2"
shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
             <from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
             <log message="${header.JMSXGroupID}"/>
        </route>            



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5737009.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by salemi <sa...@avaya.com>.
First of all many thank to you all for your suggestions, I was available to
come up with an scalable solution and our chief architect even accepted
thesolution. I can ask the JMS producers to add the JMSXGroupID header as
well as an additional header to use as an selector.

As Claus suggested we will use the JMSXGroupID header and will deploy
multiple consumers. To avoid the time spent in the splitter I decided to
remove the choice and use JMS selectors instead (see below).

<route id="1">
<from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}?concurrentConsumers=2&
amp;selector=MessageType='x1'" />
...
<route id="2">
<from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}?concurrentConsumers=2&amp;selector=MessageType='x2'"
/>
..

The only concern remains how ActiveMq performs since I am combining
selectors and group.

So far I have seen almost linear scalability by adding a new consumer. I
have done testing with 11 concurrent consumer which is enough for our
purposes.



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5737226.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by salemi <sa...@avaya.com>.
when use ?multipleConsumers=true in the
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}?multipleConsumers=true"
I get the error that it doesn't know the property.

Or do I have to use that somewhere else?



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5737025.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by Claus Ibsen <cl...@gmail.com>.
You have 2 routes with the same uri, which is not allowed by default.
You can set ?multipleConsumers=true to override that.

If you are using queues then usually just one route and then use
concurrentConsumers=X to have parallel processing.



On Thu, Aug 8, 2013 at 8:25 PM, salemi <sa...@avaya.com> wrote:
> Hi,
>
> I started to use message groups but camel throws the following exception.
> What am I doing wrong?
>
> 013-08-08 12:15:35,030 [main           ] INFO  MainSupport
> - Apache Camel 2.10.1 stopping
> Exception in thread "main" 2013-08-08 12:15:35,047 [Thread-0       ] INFO
> MainSupport$HangupInterceptor  - Received hang up - stopping the main
> instance.
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.FailedToStartRouteException: Failed to start route
> operationalreceive2 because of Multiple consumers for the same endpoint is
> not allowed: Endpoint[jms://queue:coperation]
>         at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1280)
>
> The route is as followed
> <route id="operationalsend" shutdownRunningTask="CompleteCurrentTaskOnly"
> autoStartup="false">
>                 <from
> uri="file:target/classes?fileName=operational_msgs&amp;noop=true&amp;idempotent=false"/>
>                         <log message="Processing big file: ${header.CamelFileName}"/>
>                         <delay>
>                 <constant>20000</constant>
>             </delay>
>                         <split streaming="true">
>                                 <tokenize token="\n"/>
>                                 <unmarshal ref="cJSON"/>
>                                 <process ref="jmsMessageGroupProcessor"/>
>
>                                 <marshal ref="cJSON"/>
>                                 <to uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
>                         </split>
>                         <log message="Done processing big file: ${header.CamelFileName}"/>
>                         <process ref="restartPuRouteProcessor"/>
>                         <delay>
>                 <constant>5000</constant>
>             </delay>
>         </route>
>         <route id="operationalreceive1"
> shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
>              <from
> uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
>              <log message="${header.JMSXGroupID}"/>
>         </route>
>         <route id="operationalreceive2"
> shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
>              <from
> uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
>              <log message="${header.JMSXGroupID}"/>
>         </route>
>
>
>
> -----
> Alireza Salemi
> --
> View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5737008.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by salemi <sa...@avaya.com>.
Hi,

I started to use message groups but camel throws the following exception.
What am I doing wrong?

013-08-08 12:15:35,030 [main           ] INFO  MainSupport                   
- Apache Camel 2.10.1 stopping
Exception in thread "main" 2013-08-08 12:15:35,047 [Thread-0       ] INFO 
MainSupport$HangupInterceptor  - Received hang up - stopping the main
instance.
org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToStartRouteException: Failed to start route
operationalreceive2 because of Multiple consumers for the same endpoint is
not allowed: Endpoint[jms://queue:coperation]
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1280)

The route is as followed
<route id="operationalsend" shutdownRunningTask="CompleteCurrentTaskOnly"
autoStartup="false">
    		<from
uri="file:target/classes?fileName=operational_msgs&amp;noop=true&amp;idempotent=false"/>
			<log message="Processing big file: ${header.CamelFileName}"/>
			<delay>
            	<constant>20000</constant>
            </delay>
			<split streaming="true">
				<tokenize token="\n"/>
				<unmarshal ref="cJSON"/>
				<process ref="jmsMessageGroupProcessor"/> 
                                
				<marshal ref="cJSON"/>
				<to uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
			</split>
			<log message="Done processing big file: ${header.CamelFileName}"/>
			<process ref="restartPuRouteProcessor"/>
			<delay>
                <constant>5000</constant>
            </delay>
    	</route>
        <route id="operationalreceive1"
shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
             <from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
             <log message="${header.JMSXGroupID}"/>
        </route>    	
        <route id="operationalreceive2"
shutdownRunningTask="CompleteCurrentTaskOnly" autoStartup="true">
             <from
uri="{{operational.topic.prefix}}.{{source.type}}.{{source.name}}"/>
             <log message="${header.JMSXGroupID}"/>
        </route>   



-----
Alireza Salemi
--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5737008.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Incoming message from the queue need to be send to multiple consumer but keep the ordering

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

In JMS you can use message groups for ordering
http://activemq.apache.org/message-groups.html

On Wed, Jul 10, 2013 at 5:59 AM, salemi <sa...@avaya.com> wrote:
> Hi,
> I like to implement a mechanism in Camel to receive message from a JMS
> queue. Once I have identified the type of message based on the content than
> I can forward them  to JavaSpaces. The write to JavaSpaces takes about 3ms
> so I need to parallelize the writes. But there is a catch I can't
> parallelize the messages without restrictions since there are buckets of
> messages that need to be processed in the order they have been received.
>
> Let say for example, we have message types a, b and c. All the messages of
> type "a" has to be processed in order and all the messages of type "b" has
> to be processed in order and All the messages of type "c" has to be
> processed in order.
> Is there a way to consume the messages from the JMS and split them up in to
> buckets for a, b and c and send the a, b,c messages in parallel to
> JavaSpaces?
>
> <from uri="jms:queue:abc">
>   <filter a>
>     <to start thread and save to javaspaces>
>   <filter b>
>     <to start thread and save to javaspaces>
>   <filter c>
>     <to start thread and save to javaspaces>
>
>
>
> -----
> Alireza Salemi
> --
> View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-the-queue-need-to-be-send-to-multiple-consumer-but-keep-the-ordering-tp5735406.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Incoming message from a JMS queue need to be processed in parallel but keep the ordering of messages

Posted by Gnanaguru S <gn...@wipro.com>.
Hi Salemi, 

Typically you can use content based router to categorize the messages.

http://camel.apache.org/content-based-router.html

Regards
Guru
@gnanagurus



--
View this message in context: http://camel.465427.n5.nabble.com/Incoming-message-from-a-JMS-queue-need-to-be-processed-in-parallel-but-keep-the-ordering-of-messages-tp5735406p5735410.html
Sent from the Camel - Users mailing list archive at Nabble.com.