Search in sources :

Example 1 with MethodInvokingMessageGroupProcessor

use of org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor in project spring-integration by spring-projects.

the class AggregatorFactoryBean method createHandler.

@Override
protected AggregatingMessageHandler createHandler() {
    MessageGroupProcessor outputProcessor;
    if (this.processorBean instanceof MessageGroupProcessor) {
        outputProcessor = (MessageGroupProcessor) this.processorBean;
    } else {
        if (!StringUtils.hasText(this.methodName)) {
            outputProcessor = new MethodInvokingMessageGroupProcessor(this.processorBean);
        } else {
            outputProcessor = new MethodInvokingMessageGroupProcessor(this.processorBean, this.methodName);
        }
    }
    AggregatingMessageHandler aggregator = new AggregatingMessageHandler(outputProcessor);
    if (this.expireGroupsUponCompletion != null) {
        aggregator.setExpireGroupsUponCompletion(this.expireGroupsUponCompletion);
    }
    if (this.sendTimeout != null) {
        aggregator.setSendTimeout(this.sendTimeout);
    }
    if (this.outputChannelName != null) {
        aggregator.setOutputChannelName(this.outputChannelName);
    }
    if (this.metrics != null) {
        aggregator.configureMetrics(this.metrics);
    }
    if (this.statsEnabled != null) {
        aggregator.setStatsEnabled(this.statsEnabled);
    }
    if (this.countsEnabled != null) {
        aggregator.setCountsEnabled(this.countsEnabled);
    }
    if (this.lockRegistry != null) {
        aggregator.setLockRegistry(this.lockRegistry);
    }
    if (this.messageStore != null) {
        aggregator.setMessageStore(this.messageStore);
    }
    if (this.correlationStrategy != null) {
        aggregator.setCorrelationStrategy(this.correlationStrategy);
    }
    if (this.releaseStrategy != null) {
        aggregator.setReleaseStrategy(this.releaseStrategy);
    }
    if (this.groupTimeoutExpression != null) {
        aggregator.setGroupTimeoutExpression(this.groupTimeoutExpression);
    }
    if (this.forceReleaseAdviceChain != null) {
        aggregator.setForceReleaseAdviceChain(this.forceReleaseAdviceChain);
    }
    if (this.taskScheduler != null) {
        aggregator.setTaskScheduler(this.taskScheduler);
    }
    if (this.discardChannel != null) {
        aggregator.setDiscardChannel(this.discardChannel);
    }
    if (this.discardChannelName != null) {
        aggregator.setDiscardChannelName(this.discardChannelName);
    }
    if (this.sendPartialResultOnExpiry != null) {
        aggregator.setSendPartialResultOnExpiry(this.sendPartialResultOnExpiry);
    }
    if (this.minimumTimeoutForEmptyGroups != null) {
        aggregator.setMinimumTimeoutForEmptyGroups(this.minimumTimeoutForEmptyGroups);
    }
    if (this.expireGroupsUponTimeout != null) {
        aggregator.setExpireGroupsUponTimeout(this.expireGroupsUponTimeout);
    }
    return aggregator;
}
Also used : AggregatingMessageHandler(org.springframework.integration.aggregator.AggregatingMessageHandler) MethodInvokingMessageGroupProcessor(org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor) MessageGroupProcessor(org.springframework.integration.aggregator.MessageGroupProcessor) MethodInvokingMessageGroupProcessor(org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor)

Example 2 with MethodInvokingMessageGroupProcessor

use of org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor in project spring-integration by spring-projects.

the class AggregatorParserTests method testAggregationWithExpressionsAndPojoAggregator.

@Test
public void testAggregationWithExpressionsAndPojoAggregator() {
    EventDrivenConsumer aggregatorConsumer = (EventDrivenConsumer) context.getBean("aggregatorWithExpressionsAndPojoAggregator");
    AggregatingMessageHandler aggregatingMessageHandler = (AggregatingMessageHandler) TestUtils.getPropertyValue(aggregatorConsumer, "handler");
    MethodInvokingMessageGroupProcessor messageGroupProcessor = (MethodInvokingMessageGroupProcessor) TestUtils.getPropertyValue(aggregatingMessageHandler, "outputProcessor");
    Object messageGroupProcessorTargetObject = TestUtils.getPropertyValue(messageGroupProcessor, "processor.delegate.targetObject");
    assertSame(context.getBean("aggregatorBean"), messageGroupProcessorTargetObject);
    ReleaseStrategy releaseStrategy = (ReleaseStrategy) TestUtils.getPropertyValue(aggregatingMessageHandler, "releaseStrategy");
    CorrelationStrategy correlationStrategy = (CorrelationStrategy) TestUtils.getPropertyValue(aggregatingMessageHandler, "correlationStrategy");
    Long minimumTimeoutForEmptyGroups = TestUtils.getPropertyValue(aggregatingMessageHandler, "minimumTimeoutForEmptyGroups", Long.class);
    assertTrue(ExpressionEvaluatingReleaseStrategy.class.equals(releaseStrategy.getClass()));
    assertTrue(ExpressionEvaluatingCorrelationStrategy.class.equals(correlationStrategy.getClass()));
    assertEquals(60000L, minimumTimeoutForEmptyGroups.longValue());
}
Also used : AggregatingMessageHandler(org.springframework.integration.aggregator.AggregatingMessageHandler) EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) MethodInvokingMessageGroupProcessor(org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor) CorrelationStrategy(org.springframework.integration.aggregator.CorrelationStrategy) ExpressionEvaluatingCorrelationStrategy(org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy) ExpressionEvaluatingReleaseStrategy(org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy) ReleaseStrategy(org.springframework.integration.aggregator.ReleaseStrategy) ExpressionEvaluatingReleaseStrategy(org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStrategy) ExpressionEvaluatingCorrelationStrategy(org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategy) Test(org.junit.Test)

Example 3 with MethodInvokingMessageGroupProcessor

use of org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor in project spring-integration by spring-projects.

the class AggregatorAnnotationPostProcessor method createHandler.

@Override
protected MessageHandler createHandler(Object bean, Method method, List<Annotation> annotations) {
    MethodInvokingMessageGroupProcessor processor = new MethodInvokingMessageGroupProcessor(bean, method);
    processor.setBeanFactory(this.beanFactory);
    MethodInvokingReleaseStrategy releaseStrategy = null;
    Method releaseStrategyMethod = MessagingAnnotationUtils.findAnnotatedMethod(bean, ReleaseStrategy.class);
    if (releaseStrategyMethod != null) {
        releaseStrategy = new MethodInvokingReleaseStrategy(bean, releaseStrategyMethod);
    }
    MethodInvokingCorrelationStrategy correlationStrategy = null;
    Method correlationStrategyMethod = MessagingAnnotationUtils.findAnnotatedMethod(bean, CorrelationStrategy.class);
    if (correlationStrategyMethod != null) {
        correlationStrategy = new MethodInvokingCorrelationStrategy(bean, correlationStrategyMethod);
    }
    AggregatingMessageHandler handler = new AggregatingMessageHandler(processor, new SimpleMessageStore(), correlationStrategy, releaseStrategy);
    String discardChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "discardChannel", String.class);
    if (StringUtils.hasText(discardChannelName)) {
        handler.setDiscardChannelName(discardChannelName);
    }
    String outputChannelName = MessagingAnnotationUtils.resolveAttribute(annotations, "outputChannel", String.class);
    if (StringUtils.hasText(outputChannelName)) {
        handler.setOutputChannelName(outputChannelName);
    }
    String sendPartialResultsOnExpiry = MessagingAnnotationUtils.resolveAttribute(annotations, "sendPartialResultsOnExpiry", String.class);
    if (sendPartialResultsOnExpiry != null) {
        handler.setSendPartialResultOnExpiry(Boolean.parseBoolean(this.beanFactory.resolveEmbeddedValue(sendPartialResultsOnExpiry)));
    }
    handler.setBeanFactory(this.beanFactory);
    return handler;
}
Also used : AggregatingMessageHandler(org.springframework.integration.aggregator.AggregatingMessageHandler) SimpleMessageStore(org.springframework.integration.store.SimpleMessageStore) MethodInvokingMessageGroupProcessor(org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor) Method(java.lang.reflect.Method) MethodInvokingCorrelationStrategy(org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy) MethodInvokingReleaseStrategy(org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)

Aggregations

AggregatingMessageHandler (org.springframework.integration.aggregator.AggregatingMessageHandler)3 MethodInvokingMessageGroupProcessor (org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor)3 MethodInvokingReleaseStrategy (org.springframework.integration.aggregator.MethodInvokingReleaseStrategy)2 Method (java.lang.reflect.Method)1 Test (org.junit.Test)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 SimpleMessageStore (org.springframework.integration.store.SimpleMessageStore)1