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;
}
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());
}
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;
}
Aggregations