use of org.springframework.integration.aggregator.AggregatingMessageHandler 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.AggregatingMessageHandler in project spring-integration by spring-projects.
the class ScatterGatherParserTests method testAuction.
@Test
public void testAuction() {
MessageHandler scatterGather = this.beanFactory.getBean("scatterGather1.handler", MessageHandler.class);
assertThat(scatterGather, instanceOf(ScatterGatherHandler.class));
assertSame(this.beanFactory.getBean("scatterChannel"), TestUtils.getPropertyValue(scatterGather, "scatterChannel"));
assertTrue(this.beanFactory.containsBean("scatterGather1.gatherer"));
AggregatingMessageHandler gatherer = this.beanFactory.getBean("scatterGather1.gatherer", AggregatingMessageHandler.class);
assertSame(gatherer, TestUtils.getPropertyValue(scatterGather, "gatherer"));
Object reaper = this.beanFactory.getBean("reaper");
assertSame(gatherer.getMessageStore(), TestUtils.getPropertyValue(reaper, "messageGroupStore"));
assertTrue(TestUtils.getPropertyValue(scatterGather, "requiresReply", Boolean.class));
}
use of org.springframework.integration.aggregator.AggregatingMessageHandler 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.AggregatingMessageHandler in project spring-integration by spring-projects.
the class PNamespaceTests method testPNamespaceChain.
@Test
public void testPNamespaceChain() {
List<?> handlers = (List<?>) TestUtils.getPropertyValue(sampleChain, "handler.handlers");
AggregatingMessageHandler handler = (AggregatingMessageHandler) handlers.get(0);
SampleAggregator aggregator = (SampleAggregator) TestUtils.getPropertyValue(handler, "outputProcessor.processor.delegate.targetObject");
assertEquals("Bill", aggregator.getName());
}
use of org.springframework.integration.aggregator.AggregatingMessageHandler 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