Search in sources :

Example 6 with AggregatingMessageHandler

use of org.springframework.integration.aggregator.AggregatingMessageHandler 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);
}
Also used : AggregatingMessageHandler(org.springframework.integration.aggregator.AggregatingMessageHandler) RecipientListRouter(org.springframework.integration.router.RecipientListRouter) ScatterGatherHandler(org.springframework.integration.scattergather.ScatterGatherHandler)

Example 7 with AggregatingMessageHandler

use of org.springframework.integration.aggregator.AggregatingMessageHandler 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);
}
Also used : AggregatingMessageHandler(org.springframework.integration.aggregator.AggregatingMessageHandler) ScatterGatherHandler(org.springframework.integration.scattergather.ScatterGatherHandler)

Aggregations

AggregatingMessageHandler (org.springframework.integration.aggregator.AggregatingMessageHandler)7 Test (org.junit.Test)3 MethodInvokingMessageGroupProcessor (org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor)3 ScatterGatherHandler (org.springframework.integration.scattergather.ScatterGatherHandler)3 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)2 Method (java.lang.reflect.Method)1 List (java.util.List)1 CorrelationStrategy (org.springframework.integration.aggregator.CorrelationStrategy)1 ExpressionEvaluatingCorrelationStrategy (org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy)1 ExpressionEvaluatingReleaseStrategy (org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy)1 MessageGroupProcessor (org.springframework.integration.aggregator.MessageGroupProcessor)1 MethodInvokingCorrelationStrategy (org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy)1 ReleaseStrategy (org.springframework.integration.aggregator.ReleaseStrategy)1 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)1 RecipientListRouter (org.springframework.integration.router.RecipientListRouter)1 SimpleMessageStore (org.springframework.integration.store.SimpleMessageStore)1 MessageHandler (org.springframework.messaging.MessageHandler)1