Skip to content

Commit af609ca

Browse files
Change the default polling trigger to 1 second (#8751)
* Change the default polling trigger to 1 second The current default trigger for the poller is 10 milliseconds fixed delay. This is very tight policy for Microservices where we might not have too many scheduled threads to distribute polling endpoint jobs evenly. * Change the default trigger to 1 second to align with what Spring Boot already claims. Same 1 second policy is used in Spring Cloud Stream as well * Fix language in Docs Co-authored-by: Gary Russell <[email protected]> --------- Co-authored-by: Gary Russell <[email protected]>
1 parent fa06940 commit af609ca

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

Diff for: spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
8787
/**
8888
* A default polling period for {@link PeriodicTrigger}.
8989
*/
90-
public static final long DEFAULT_POLLING_PERIOD = 10;
90+
public static final long DEFAULT_POLLING_PERIOD = 1000;
9191

9292
private final Collection<Advice> appliedAdvices = new HashSet<>();
9393

Diff for: spring-integration-core/src/test/java/org/springframework/integration/configuration/EnableIntegrationTests.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -667,13 +667,16 @@ public void testBridgeAnnotations() {
667667
assertThat(testMessage).isSameAs(receive);
668668
assertThat(this.bridgeOutput.receive(10)).isNull();
669669

670+
PollingConsumer pollableBridge = this.context.getBean("pollableBridge", PollingConsumer.class);
671+
PeriodicTrigger periodicTrigger = TestUtils.getPropertyValue(pollableBridge, "trigger", PeriodicTrigger.class);
672+
assertThat(periodicTrigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(1));
673+
670674
this.pollableBridgeInput.send(testMessage);
671675
receive = this.pollableBridgeOutput.receive(10_000);
672676
assertThat(receive).isNotNull();
673677
assertThat(testMessage).isSameAs(receive);
674678
assertThat(this.pollableBridgeOutput.receive(10)).isNull();
675679

676-
677680
assertThatExceptionOfType(MessageDeliveryException.class)
678681
.isThrownBy(() -> this.metaBridgeInput.send(testMessage))
679682
.withMessageContaining("Dispatcher has no subscribers");
@@ -948,7 +951,8 @@ public PollableChannel pollableBridgeInput() {
948951

949952

950953
@Bean
951-
@BridgeFrom(value = "pollableBridgeInput", poller = @Poller(fixedDelay = "1000"))
954+
@BridgeFrom(value = "pollableBridgeInput", poller = @Poller)
955+
@EndpointId("pollableBridge")
952956
public QueueChannel pollableBridgeOutput() {
953957
return new QueueChannel();
954958
}

Diff for: src/reference/antora/modules/ROOT/pages/channel-adapter.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ See also xref:channel-adapter.adoc#channel-adapter-expressions-and-scripts[Chann
8989
NOTE: If no poller is provided, then a single default poller must be registered within the context.
9090
See xref:endpoint.adoc#endpoint-namespace[Endpoint Namespace Support] for more detail.
9191

92+
NOTE: The default trigger for polling endpoint is a `PeriodicTrigger` instance with a 1 second fixed delay period.
93+
9294
[IMPORTANT]
9395
.Important: Poller Configuration
9496
=====

Diff for: src/reference/antora/modules/ROOT/pages/endpoint.adoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ PollingConsumer consumer = new PollingConsumer(channel, exampleHandler);
7979
NOTE: For more information regarding polling consumers, see xref:overview.adoc#overview-endpoints-channeladapter[Channel Adapter] and xref:channel-adapter.adoc#channel-adapter[Channel Adapter].
8080

8181
There are many other configuration options for the polling consumer.
82-
For example, the trigger is a required property.
8382
The following example shows how to set the trigger:
8483

8584
[source,java]
@@ -112,6 +111,8 @@ CronTrigger trigger = new CronTrigger("*/10 * * * * MON-FRI");
112111

113112
The result of the trigger defined in the previous example is a trigger that triggers every ten seconds, Monday through Friday.
114113

114+
NOTE: The default trigger for polling endpoint is a `PeriodicTrigger` instance with a 1 second fixed delay period.
115+
115116
In addition to the trigger, you can specify two other polling-related configuration properties: `maxMessagesPerPoll` and `receiveTimeout`.
116117
The following example shows how to set these two properties:
117118

Diff for: src/reference/antora/modules/ROOT/pages/whats-new.adoc

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ See xref:gateway.adoc#gateway-no-response[Gateway Behavior When No response Arri
4242
- The `LockRegistry` provides template-like API to execute provided task while locked.
4343
See xref:distributed-locks.adoc[Distributed Locks] for more information.
4444

45+
- The default trigger for polling endpoint is now a `PeriodicTrigger` instance with a 1 second fixed delay period; previously, the default was 10 milliseconds.
46+
See xref:endpoint.adoc#endpoint-pollingconsumer[Polling Consumer] for more information.
47+
4548
[[x6.2-websockets]]
4649
=== WebSockets Changes
4750

0 commit comments

Comments
 (0)