Hi Team ,

Could you please update on this.

The problem I'm facing is My Splitter is working with Aggregate in Java DSL
but ot in XML Dsl.

The following Java DSL code is working fine as expected

@Component
public class DataRoute extends RouteBuilder {
    @Override
    public void configure() throws Exception {
        from("file:C:\\Users\\sahil\\Desktop\\Source")
                .split().jsonpath("$")
                .aggregate(constant(true), new
GroupedBodyAggregationStrategy())
                .completionSize(10)
                .completionTimeout(1000)
                .marshal().json(JsonLibrary.Jackson)
                .log("${body}")
                .to("file:C:\\Users\\sahil\\Desktop\\Destination");
    }
}

It is successfully splitting Big JSON Array in batches of 10.

But I am facing issue with xml dsl that it not considering *completionSize*
attribute.

Below is my Xml dsl code snippet


<bean id="myStrategy"
class="org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy"/>


<route>
    < from uri : splitter>
    <split>
        <jsonpath>$</jsonpath>
        <aggregate aggregationStrategy= "myStrategy"
                   *completionSize="10"* completionTimeout="1000">
            <correlationExpression>
                <constant>true</constant>
            </correlationExpression>
            <marshal>
                <json></json>
            </marshal>
        </aggregate
    </split>
    < to uri : transformer>
</route>


This is splitting Big Json Array Say of size 100 into batches of 1 and not 10.

Can you please suggest how to achieve this.

Regards
Sahil

On Mon, May 22, 2023 at 10:39 AM Sahil Upneja <upnej...@gmail.com> wrote:

> Hi Claus ,
>
> Yes Jsonpath is correct
>
> The following java DSL code is working fine as expected
>
> @Component
> public class DataRoute extends RouteBuilder {
>     @Override
>     public void configure() throws Exception {
>         from("file:C:\\Users\\sahil\\Desktop\\Source")
>                 .split().jsonpath("$")
>                 .aggregate(constant(true), new
> GroupedBodyAggregationStrategy())
>                 .completionSize(10)
>                 .completionTimeout(1000)
>                 .marshal().json(JsonLibrary.Jackson)
>                 .log("${body}")
>                 .to("file:C:\\Users\\sahil\\Desktop\\Source");
>     }
> }
>
> It is successfully splitting in batches of 10.
>
> But I am facing issue with xml dsl that it not considering completionSize
> attribute.
>
> Can you please suggest on this.
>
> Regards
> Sahil
>
> On Sat, May 20, 2023 at 1:44 PM Claus Ibsen <claus.ib...@gmail.com> wrote:
>
>> Hi
>>
>> Are you sure jsonpath $ will return a list or something that can be
>> iterated for the splitter to turn into 10 elements.
>> As you have timeout 1s then it may be that this is what causes the output
>> of the trigger.
>>
>> Make sure you jsonpath is correct, there are online jsonpath validators
>> you
>> can try with your json sample input
>>
>> On Fri, May 19, 2023 at 11:55 PM Sahil Upneja <upnej...@gmail.com> wrote:
>>
>> > Hi Team,
>> >
>> > I am not able to use aggregate with Splitter in Camel Version 3.20.0.
>> >
>> > *completionSize* is not getting considered when I am using Aggregate
>> inside
>> > the Splitter
>> >
>> > Splitter is splitting in batches of 1 only, but I want to split Json
>> array
>> > of large size say 100 into batches of 10.
>> >
>> > Below is my code snippet
>> >
>> >
>> > <bean id="myStrategy"
>> >
>> >
>> class="org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy"/>
>> >
>> >
>> > <route>
>> >     < from uri : splitter>
>> >     <split>
>> >         <jsonpath>$</jsonpath>
>> >         <aggregate aggregationStrategy= "myStrategy"
>> >                    *completionSize="10"* completionTimeout="1000">
>> >             <correlationExpression>
>> >                 <constant>true</constant>
>> >             </correlationExpression>
>> >             <marshal>
>> >                 <json></json>
>> >             </marshal>
>> >         </aggregate
>> >     </split>
>> >     < to uri : transformer>
>> > </route>
>> >
>> >
>> > Can you please suggest how to achieve this.
>> >
>> > Thanks & Regards
>> >
>> > Sahil
>> >
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> @davsclaus
>> Camel in Action 2: https://www.manning.com/ibsen2
>>
>

Reply via email to