3

I'm relatively new to Camel (2.24.x) and am trying to use the AggregationStrategy in the Java DSL but have a few related issues/concerns. Also please note that while I'm choosing to use the Java DSL I would also accept answers/explanations in Spring Camel XML format, if that's the best I can get my hands on!

I'm trying to use AggregationStrategy like a "valve", meaning, collect/aggregate inbound exchanges until it determines that its ready to move that aggregated exchange on to the rest of the route, but not allow any exchanges/messages past it until it makes that determination. So essentially, this "valve" (aggregator) is closed until it determines it has adequately aggregated 1+ exchanges, and then it "opens" once it makes that determination.

To implement the AggregationStrategy interface, the barebones code is this:

public class RunValve implements AggregationStrategy {

    @Override
    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
        return null;
    }

}

What does oldExchange and newExchange correspond to? Is oldExchange the one that we are aggregating, and newExchange is simply the next message that we can (optionally) append to the oldExchange? What should the aggregate(...) method return, the oldExchange or the newExchange? Or something else?!

And then, once I've determined (inside the aggregate(...) method) that its time to "open the valve" (e.g. that we have successfully aggregated 100%), how do I tell Camel to allow the aggregated exchange through to the rest of the route?

Thanks in advance for any-and-all insight!

hotmeatballsoup
  • 385
  • 6
  • 58
  • 136
  • This is typical use case for [pollEnrich EIP](https://camel.apache.org/manual/latest/pollEnrich-eip.html), type of [Content Enricher](https://camel.apache.org/manual/latest/content-enricher.html) – Bedla Jan 21 '20 at 21:05
  • Thanks @Bedla I don't think either of those EIPs support the "valve" concept that is crucial to what I need. – hotmeatballsoup Jan 22 '20 at 01:34

0 Answers0