Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class CheapeastFlightAggregationStrategy implements AggregationStrategy {
public MuleEvent aggregate(AggregationContext context) throws MuleException {
MuleEvent result = null;
long value = Long.MAX_VALUE;
for (MuleEvent event : context.collectEventsWithoutExceptions()) {
Flight flight = (Flight) event.getMessage().getPayload();
if (flight.getCost() < value) {
result = DefaultMuleEvent.copy(event);
value = flight.getCost();
if (result != null) {
return result;
throw new RuntimeException("no flights obtained");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.