diff --git a/build.gradle b/build.gradle index ce83fed0ed..07a4a0e295 100644 --- a/build.gradle +++ b/build.gradle @@ -195,6 +195,7 @@ subprojects { subproject -> } test { + maxHeapSize = "1024m" jvmArgs "-javaagent:${configurations.jacoco.asPath}=destfile=${buildDir}/jacoco.exec,includes=org.springframework.integration.*" } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/InboundChannelAdapter.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/InboundChannelAdapter.java index ea4c043b35..f63aae326d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/InboundChannelAdapter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/annotation/InboundChannelAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,6 +43,7 @@ import java.lang.annotation.Target; * * * @author Artem Bilan + * @author Gary Russell * @since 4.0 */ @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @@ -69,6 +70,8 @@ public @interface InboundChannelAdapter { * ({@link org.springframework.integration.scheduling.PollerMetadata}). * This attribute is an {@code array} just to allow an empty default (no poller). * Only one {@link org.springframework.integration.annotation.Poller} element is allowed. + * NOTE: a {@link Poller} here has {@link Poller#maxMessagesPerPoll()} set to 1 by default. */ Poller[] poller() default {}; + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Poller.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Poller.java index 9adbb3fc67..4b1848e038 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Poller.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Poller.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,9 +22,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; import org.springframework.integration.scheduling.PollerMetadata; +import org.springframework.scheduling.Trigger; import org.springframework.scheduling.support.CronTrigger; import org.springframework.scheduling.support.PeriodicTrigger; -import org.springframework.scheduling.Trigger; /** * Provides the {@link PollerMetadata} options for the Messaging annotations for @@ -39,6 +39,7 @@ import org.springframework.scheduling.Trigger; * Non-reference attributes support Property Placeholder resolutions. * * @author Artem Bilan + * @author Gary Russell * @since 4.0 */ @Target({}) @@ -63,6 +64,7 @@ public @interface Poller { /** * @return The maximum number of messages to receive for each poll. * Can be specified as 'property placeholder', e.g. {@code ${poller.maxMessagesPerPoll}}. + * Defaults to -1 (infinity) for polling consumers and 1 for polling inbound channel adapters. */ String maxMessagesPerPoll() default ""; @@ -83,4 +85,5 @@ public @interface Poller { * Can be specified as 'property placeholder', e.g. {@code ${poller.cron}}. */ String cron() default ""; + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java index 54a037b527..707da67b59 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,6 +50,7 @@ import org.springframework.integration.endpoint.AbstractEndpoint; import org.springframework.integration.endpoint.AbstractPollingEndpoint; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.endpoint.PollingConsumer; +import org.springframework.integration.endpoint.SourcePollingChannelAdapter; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.scheduling.PollerMetadata; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; @@ -247,7 +248,7 @@ public abstract class AbstractMethodAnnotationPostProcessor @@ -288,7 +288,7 @@ A reference to a bean that implements 'org.springframework.integration.store.PriorityCapableChannelMessageStore'. A message store that supports priority in a manner defined by the store. When set, the underlying - channel will be a 'QueueChannel` that delegates to a `MessageGroupQueue' backed by the store. + channel will be a 'QueueChannel' that delegates to a 'MessageGroupQueue' backed by the store. Not allowed if 'comparator' is set. @@ -1772,8 +1772,23 @@ - - + + + + Run each poll task in a transaction; mutually exclusive + with 'advice-chain'; add a transaction advice if you need transactions + in addition to other advices. + + + + + + + A chain of nested AOP 'Advice' objects applied to the poller task. + Mutually exclusive with 'transactional'. + + + @@ -1826,8 +1841,25 @@ - - + + + + Only applies to polling consumers - the time the poll thread will wait + after the trigger for a new message to arrive. Defaults to 1000 (1 second). + For polled inbound channel adapters, whether or not the polling thread blocks is + dependent on the message source implementation. + + + + + + + The maximum number of messages that will be produced for each poll. Defaults to + infinity (indicated by -1) for polling consumers, and 1 for polled + inbound channel adapters. + + + diff --git a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java index 5b1633320e..872328a533 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -374,6 +374,9 @@ public class EnableIntegrationTests { Message message = this.fooChannel.receive(1000); assertNotNull(message); assertEquals("foo", message.getPayload()); + message = this.fooChannel.receive(1000); + assertNotNull(message); + assertEquals("foo", message.getPayload()); assertNull(this.fooChannel.receive(10)); message = this.messageChannel.receive(1000); @@ -1151,7 +1154,8 @@ public class EnableIntegrationTests { } @Override - @InboundChannelAdapter(value = "fooChannel", poller = @Poller(trigger = "onlyOnceTrigger", maxMessagesPerPoll = "1")) + @InboundChannelAdapter(value = "fooChannel", + poller = @Poller(trigger = "onlyOnceTrigger", maxMessagesPerPoll = "2")) public String foo() { return "foo"; } diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java index 3b72e6009f..e2e60890ae 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java @@ -74,6 +74,7 @@ public class StoredProcJavaConfigTests { Collection primes = (Collection) received.getPayload(); assertThat(primes, Matchers.contains(2, 3, 5, 7)); received = fooChannel.receive(100); + // verify maxMessagesPerPoll == 1 assertNull(received); } @@ -87,7 +88,7 @@ public class StoredProcJavaConfigTests { } @Bean - @InboundChannelAdapter(value = "fooChannel", poller = @Poller(fixedDelay="5000", maxMessagesPerPoll = "1")) + @InboundChannelAdapter(value = "fooChannel", poller = @Poller(fixedDelay="5000")) public MessageSource storedProc() { StoredProcPollingChannelAdapter source = new StoredProcPollingChannelAdapter(storedProcExecutor()); source.setExpectSingleResult(true); diff --git a/src/reference/docbook/whats-new.xml b/src/reference/docbook/whats-new.xml index a0f395d235..1a60a9f891 100644 --- a/src/reference/docbook/whats-new.xml +++ b/src/reference/docbook/whats-new.xml @@ -47,5 +47,14 @@ See for more information. +
+ @InboundChannelAdapter + + Previously, the @Poller on an inbound channel adapter defaulted + the maxMessagesPerPoll attribute to -1 (infinity). This was inconsistent + with the XML configuration of <inbound-channel-adapter/>s, which defaults + to 1. The annotation now defaults this attribute to 1. + +