use of org.springframework.integration.scattergather.ScatterGatherHandler in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method scatterGather.
/**
* Populate a {@link ScatterGatherHandler} to the current integration flow position
* based on the provided {@link RecipientListRouterSpec} for scattering function
* and {@link AggregatorSpec} for gathering function.
* @param scatterer the {@link Consumer} for {@link RecipientListRouterSpec} to configure scatterer.
* @param gatherer the {@link Consumer} for {@link AggregatorSpec} to configure gatherer.
* @param scatterGather the {@link Consumer} for {@link ScatterGatherSpec} to configure
* {@link ScatterGatherHandler} and its endpoint. Can be {@code null}.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B scatterGather(Consumer<RecipientListRouterSpec> scatterer, Consumer<AggregatorSpec> gatherer, Consumer<ScatterGatherSpec> scatterGather) {
Assert.notNull(scatterer, "'scatterer' must not be null");
RecipientListRouterSpec recipientListRouterSpec = new RecipientListRouterSpec();
scatterer.accept(recipientListRouterSpec);
AggregatorSpec aggregatorSpec = new AggregatorSpec();
if (gatherer != null) {
gatherer.accept(aggregatorSpec);
}
RecipientListRouter recipientListRouter = recipientListRouterSpec.get().getT2();
addComponent(recipientListRouter).addComponents(recipientListRouterSpec.getComponentsToRegister());
AggregatingMessageHandler aggregatingMessageHandler = aggregatorSpec.get().getT2();
addComponent(aggregatingMessageHandler);
ScatterGatherHandler messageHandler = new ScatterGatherHandler(recipientListRouter, aggregatingMessageHandler);
return register(new ScatterGatherSpec(messageHandler), scatterGather);
}
use of org.springframework.integration.scattergather.ScatterGatherHandler in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method scatterGather.
/**
* Populate a {@link ScatterGatherHandler} to the current integration flow position
* based on the provided {@link MessageChannel} for scattering function
* and {@link AggregatorSpec} for gathering function.
* @param scatterChannel the {@link MessageChannel} for scatting requests.
* @param gatherer the {@link Consumer} for {@link AggregatorSpec} to configure gatherer.
* Can be {@code null}.
* @param scatterGather the {@link Consumer} for {@link ScatterGatherSpec} to configure
* {@link ScatterGatherHandler} and its endpoint. Can be {@code null}.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B scatterGather(MessageChannel scatterChannel, Consumer<AggregatorSpec> gatherer, Consumer<ScatterGatherSpec> scatterGather) {
AggregatorSpec aggregatorSpec = new AggregatorSpec();
if (gatherer != null) {
gatherer.accept(aggregatorSpec);
}
AggregatingMessageHandler aggregatingMessageHandler = aggregatorSpec.get().getT2();
addComponent(aggregatingMessageHandler);
ScatterGatherHandler messageHandler = new ScatterGatherHandler(scatterChannel, aggregatingMessageHandler);
return register(new ScatterGatherSpec(messageHandler), scatterGather);
}
Aggregations