Jan Bednar created CAMEL-15640:
----------------------------------

             Summary: Partition component/EIP
                 Key: CAMEL-15640
                 URL: https://issues.apache.org/jira/browse/CAMEL-15640
             Project: Camel
          Issue Type: New Feature
            Reporter: Jan Bednar
            Assignee: Jan Bednar


Sometimes you need to process messages in parallel and also ensure order of 
messages per key. Kafka is great for this with its partitioning and ActiveMQ 
with message groups, but in small single instance project may be broker 
overkill.

I needed that feature in one project and solved it with something what doesnt 
look nice, similar to this pseudo code:
{code:java}
final int consumers = 10;
from("direct:source")
    .process(exchange ->
            exchange.getMessage().setHeader("partition",
                    exchange.getMessage().getHeader("partition_key")
                            .hashCode() % consumers)
    )
    .toD("seda:partition_${header.partition}");

for (int i = 0; i < consumers; i++) {
    from("seda:partition_" + i)
            .to("direct:target");
}
{code}
It would be great to have something like Partition component (*or maybe better 
Partition EIP?*)

It can be similar to seda, but with following features.
 * Pluggable PartitionStrategy with pluggable Expression for partition key. 
Default can be HashPartitionStrategy.
 * Message will be assigned to Thread based on following algorithm: 
_target_thread_id = hash % concurrentConsumers_

 

 

*Community feedback/discussion about this feature welcomed.*



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to