I have the following situation:
- There are a fixed number of groups.
- There is a TCP stream of incoming messages. Each message is related to exactly one group.
I start the Camel route as following:
public class MyMessage implements Runnable {
public void run() {
// omitted here
}
}
from("netty:tcp://localhost:7777?textline=true&sync=false")
... // omitted here: parse message to pojo MyMessage, set header "group-identifier"
.to(seda:process);
This Camel route consumes the TCP stream, parses and converts the payload of each incoming message to a MyMessage
pojo and sets the group-identifier
header on the exchange which corresponds with a message...
Now I want to consume seda:process
as following:
- Messages belonging the same group cannot be executed concurrently.
- Messages belonging to different groups can be executed concurrently.
- Each messages should be executed by calling
run()
. I want to provide/define anExecutorService
for this, so I can control the number of threads.
Which enterprise integration patterns can I apply here? How can I map these concepts to Camel?
I learnt that ActiveMQ has the concept of message groups (http://activemq.apache.org/message-groups.html). This might provide a way to make sure that two messages of the same group will never be executed at the same time. Though, I am not sure that introducing ActiveMQ only for this isn't overkill. Can this also be achieved with 'core' Camel/Java?