You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Paulius Gasėnas <Pa...@etic.lt> on 2013/05/14 08:40:23 UTC

How to make route wait for aggregator to aggregate?

Hi guys,

I‘m new to this forum.

We have an issue with multicast and aggregation.
Before calling route direct:putEvent, header correlationId  is also set, so correlation is working. Goal, that we are trying to achieve here, is that we need, that after message is sent to routeX, which sends message to rabbitmq:toQueue , after some time message is received in routeY , thus both messages can be aggregated in the aggregator, if their correlationId coincides. The problem here is that first route is not waiting for second message from routeY to arrive to aggregator, and returns right away. How can we make first route to wait until completionTimeout or completionSize conditions are satisfied?

Code:
        <camel:route id="routeX">
            <camel:from uri="direct:putEvent" />
            <camel:multicast stopOnException="true" parallelProcessing="false">
                <camel:to uri="rabbitmq:toQueue" />
                <camel:to uri="direct:toAggregator" />
            </camel:multicast>
        </camel:route>

        <camel:route id="routeY">
            <camel:from uri="rabbitmq:fromOtherQueue" />
            <camel:setHeader headerName="correlationId">
                <camel:xpath resultType="java.lang.String">//event[1]//id[1]</camel:xpath>
            </camel:setHeader>
            <camel:to uri="direct:toAggregator" />
        </camel:route>

        <camel:route id="aggregationRoute">
            <camel:from uri="direct:toAggregator" />
            <camel:aggregate strategyRef="myStrategy" completionTimeout="7000" parallelProcessing="false"
                eagerCheckCompletion="false">
                <!-- aggregate all messages into the same group -->
                <camel:correlationExpression>
                    <camel:simple>header.correlationId</camel:simple>
                </camel:correlationExpression>
                <camel:completionSize>
                    <camel:simple>2</camel:simple>
                </camel:completionSize>
            </camel:aggregate>
        </camel:route>

Thanks in advance.


----------------------------------------------------------------------
Šioje žinutėje ir bet kokiuose jos prieduose pateikiama informacija yra konfidenciali ir jos panaudojimas ar atskleidimas gali būti apribotas. Ji skirta tik tam asmeniui, kuriam ji adresuota. Jei Jūs nesate adresatas arba atsakingas už šios žinutės pristatymą tam asmeniui, Jūs neturite teisės šios žinutės ar jos priedų kopijuoti, atskleisti, platinti ar kitaip perduoti jos turinio bet kuriam kitam asmeniui. Jei Jūs per klaidą gavote šią žinutę, prašome nedelsiant pranešti jos siuntėjui bei iškart ištrinti šią žinutę ir bet kokius jos priedus iš Jūsų sistemos.
----------------------------------------------------------------------