Hi

You can add a custom header or exchange property in the filer, which
you can then read in the aggregation strategy to know if you want to
include the message or not.

On Fri, Jan 7, 2022 at 12:15 PM Jörg Jansen
<joerg.jan...@inform-software.com> wrote:
>
> Dear all,
>
> I'm currently migrating my application from camel 3.7 to the latest LTS.
> While stepping through the migration guide, I recognized, that the 
> FILTER_MATCHED property is deprecated/removed.
>
> I think, filtering messaged within a split block is not a very rare scenario.
> What is the best approach to ignore those messages?
>
> From my point of view, it would be the correct way, that those messages would 
> not enter the aggregator, but currently, all messages are passed.
>
> A simple example route could be:
>
> from("direct:start")
>   .split().body()
>     .aggregationStrategy((o,n) ->  {
>       // should only receive valid messages
>       return n;
>     })
>     .filter(bodyAs(String.class).isEqualTo("invalid"))
>       .log(LoggingLevel.INFO, "new invalid message received: ${body}")
>       // Ignore the message
>     .end()
>   .end()
> .to("mock:result")
> ;
>
> My current workaround is to set the body to null and filter all null bodies 
> within the aggregator, but I don't think that's the best solution.
>
> Any hint would be very helpful.
>
> Kind regards,
> Joerg



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to