Вот моя текущая настройка:
Код: Выделить всё
public class IntCon {
@Bean
public MessageChannel inputChannel1() {
return new DirectChannel();
}
@Bean
public MessageChannel inputChannel2() {
return new DirectChannel();
}
@Bean
public MessageChannel outputChannel() {
return new DirectChannel();
}
@SuppressWarnings("unchecked")
@Bean
public IntegrationFlow vinylArchiveFlow() {
return IntegrationFlow
.from("inputChannel1")
.handle((payload, headers) -> {
List records = (List) payload;
VinylRecord lastVinyl = records.getLast();
return MessageBuilder.withPayload(lastVinyl)
.setHeader("lastVinyl", true)
.copyHeaders(headers)
.build();
})
.channel("outputChannel")
.get();
}
@SuppressWarnings("unchecked")
@Bean
public IntegrationFlow cdArchiveFlow() {
return IntegrationFlow
.from("inputChannel2")
.handle((payload, headers) -> {
List records = (List) payload;
CdRecord lastCD = records.getLast();
return MessageBuilder.withPayload(lastCD)
.setHeader("lastCD", true)
.copyHeaders(headers)
.build();
})
.channel("outputChannel")
.get();
}
}
Код: Выделить всё
@Aggregator(inputChannel = "outputChannel", outputChannel = "willDefineLater")
public Message aggregate(final List message : messages) {
// Store the message for later
messageStore.addMessage(message);
// Check the message for the headers
if (Boolean.TRUE.equals(message.getHeaders().get("lastVinyl"))) {
isLastVinyl = true; // Set isLastVinyl to true
}
if (Boolean.TRUE.equals(message.getHeaders().get("lastCD"))) {
isLastCD = true; // Set isLastCD to true
}
}
return ...;
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... types-into