Pergunta

I have a route where I want Camel to visit the following beans:

  1. First, loggingBean
  2. Second, an aggregator that waits for a certain number of messages to aggregate on it
  3. Once the Aggregator's completionSize is reached (3), keep going to #4
  4. Third, processorBean
  5. And fourth/last, finalizerBean

Here is my route:

<route id="my-camel-route"> 
    <from uri="direct:starter" />

    <to uri="bean:loggingBean?method=shutdown" />

    <aggregate strategyRef="myAggregationStrategy" completionSize="3">
        <correlationExpression> 
            <simple>${header.id} == 1</simple> 
        </correlationExpression>
        <to uri="bean:processorBean?method=process" /> 
    </aggregate> 

    <to uri="bean:finalizerBean?method=shutdown" />
</route>

My question: do I need to place finalizerBean inside the <aggregate> element like so:

<aggregate strategyRef="myAggregationStrategy" completionSize="3">
    <correlationExpression> 
        <simple>${header.id} == 1</simple> 
    </correlationExpression>
    <to uri="bean:processorBean?method=process" /> 
    <to uri="bean:finalizerBean?method=shutdown" /> 
</aggregate> 

Basically, I'm wondering if the way I currently have things will prompt Camel to send the message to the aggregator, and then also send it on to finalizerBean (essentially, bypassing the aggregator). In my case, I want it to aggregate until completionSize is 3, and then send the aggregated exchange on to the processorBean and then finally finalizerBean.

Or have I configured this correctly? What's the difference between finalizerBean being inside the <aggregate> element vs being outside it?

Foi útil?

Solução

The second example is correct.

<aggregate strategyRef="myAggregationStrategy" completionSize="3">
    <correlationExpression> 
        <simple>${header.id} == 1</simple> 
    </correlationExpression>
    <to uri="bean:processorBean?method=process" /> 
    <to uri="bean:finalizerBean?method=shutdown" /> 
</aggregate>

If finalizerBean is "outside" the <aggregate>, it will get executed for every message that comes from direct:starter - which isn't what you want ;)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top