Help understand Exchange.AGGREGATION_COMPLETE_ALL_GROUPS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help understand Exchange.AGGREGATION_COMPLETE_ALL_GROUPS

hakuseki
Hi, guys

The dopcumentation states that to manually trigger a completion of an aggregation you could send a message with the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true and it will be considered a trigger message to start completion of all aggreations.


This is not working for me and my route…
I get an error message saying my payload is null and that Camel can’t find a converter

org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream on: JmsMessage[JmsMessageID: ID:MAW-MacBook-Space.local-53257-1570102789119-1:6:1:1:1]. Caused by: No type converter available to convert from type: null to the required type: java.io.InputStream with value null. Exchange[ID-MAW-MacBook-Space-local-1570102785170-0-3]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: null to the required type: java.io.InputStream with value null]


I figure that much out because the message I send is empty and the header mentioned is only present.
The documentation states:

You can manually trigger completion of all current aggregated exchanges by sending a message containing the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true. The message is considered a signal message only, the message headers/contents will not be processed otherwise.

The other header (Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE) can be used as a EOF indicator where we process the message using a correct payload but trigger the aggregation completion as well.



So how should we use this header?

Do I need to add a choice of somekind prior to my payload processing or?

Thx

M


Reply | Threaded
Open this post in threaded view
|

Re: Help understand Exchange.AGGREGATION_COMPLETE_ALL_GROUPS

Claus Ibsen-2
Hi

A good idea is to look at the unit tests of camel itself.
There you can search the source code where this header are used, and
find unit tests that use it to be inspired.

For the documentation, then you are welcome to help update and we
accept PRs, there is a "edit this page" button.

On Thu, Oct 3, 2019 at 1:56 PM Mikael Andersson Wigander
<[hidden email]> wrote:

>
> Hi, guys
>
> The dopcumentation states that to manually trigger a completion of an aggregation you could send a message with the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true and it will be considered a trigger message to start completion of all aggreations.
>
>
> This is not working for me and my route…
> I get an error message saying my payload is null and that Camel can’t find a converter
>
> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream on: JmsMessage[JmsMessageID: ID:MAW-MacBook-Space.local-53257-1570102789119-1:6:1:1:1]. Caused by: No type converter available to convert from type: null to the required type: java.io.InputStream with value null. Exchange[ID-MAW-MacBook-Space-local-1570102785170-0-3]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: null to the required type: java.io.InputStream with value null]
>
>
> I figure that much out because the message I send is empty and the header mentioned is only present.
> The documentation states:
>
> You can manually trigger completion of all current aggregated exchanges by sending a message containing the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true. The message is considered a signal message only, the message headers/contents will not be processed otherwise.
>
> The other header (Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE) can be used as a EOF indicator where we process the message using a correct payload but trigger the aggregation completion as well.
>
>
>
> So how should we use this header?
>
> Do I need to add a choice of somekind prior to my payload processing or?
>
> Thx
>
> M
>
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Reply | Threaded
Open this post in threaded view
|

Re: Help understand Exchange.AGGREGATION_COMPLETE_ALL_GROUPS

hakuseki
Thx Claus!

I fígured it out to be if you have ANY processing BEFORE the aggregation you MUST send a valid message as payload.

In my route I'm suppose to get a json as payload and by sending a “fake” json it the proceeds as intended.

from("{{shuttle.jms.incoming}}")
    .routeId("SHUTTLE")
    .autoStartup("{{shuttle.autostart}}")
    .unmarshal().json(JsonLibrary.Jackson, true)
    .aggregate(constant(true), new ArrayListAggregationStrategy())
    .aggregationRepository(shuttleRepo)
    .parallelProcessing(false)

I’ll update the docs ;)

M

> On 3 Oct 2019, at 14:11, Claus Ibsen <[hidden email]> wrote:
>
> Hi
>
> A good idea is to look at the unit tests of camel itself.
> There you can search the source code where this header are used, and
> find unit tests that use it to be inspired.
>
> For the documentation, then you are welcome to help update and we
> accept PRs, there is a "edit this page" button.
>
> On Thu, Oct 3, 2019 at 1:56 PM Mikael Andersson Wigander
> <[hidden email]> wrote:
>>
>> Hi, guys
>>
>> The dopcumentation states that to manually trigger a completion of an aggregation you could send a message with the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true and it will be considered a trigger message to start completion of all aggreations.
>>
>>
>> This is not working for me and my route…
>> I get an error message saying my payload is null and that Camel can’t find a converter
>>
>> org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream on: JmsMessage[JmsMessageID: ID:MAW-MacBook-Space.local-53257-1570102789119-1:6:1:1:1]. Caused by: No type converter available to convert from type: null to the required type: java.io.InputStream with value null. Exchange[ID-MAW-MacBook-Space-local-1570102785170-0-3]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: null to the required type: java.io.InputStream with value null]
>>
>>
>> I figure that much out because the message I send is empty and the header mentioned is only present.
>> The documentation states:
>>
>> You can manually trigger completion of all current aggregated exchanges by sending a message containing the header Exchange.AGGREGATION_COMPLETE_ALL_GROUPS set to true. The message is considered a signal message only, the message headers/contents will not be processed otherwise.
>>
>> The other header (Exchange.AGGREGATION_COMPLETE_ALL_GROUPS_INCLUSIVE) can be used as a EOF indicator where we process the message using a correct payload but trigger the aggregation completion as well.
>>
>>
>>
>> So how should we use this header?
>>
>> Do I need to add a choice of somekind prior to my payload processing or?
>>
>> Thx
>>
>> M
>>
>>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2