Skip to content

Change the default polling trigger to 1 second #8751

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
/**
* A default polling period for {@link PeriodicTrigger}.
*/
public static final long DEFAULT_POLLING_PERIOD = 10;
public static final long DEFAULT_POLLING_PERIOD = 1000;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,16 @@ public void testBridgeAnnotations() {
assertThat(testMessage).isSameAs(receive);
assertThat(this.bridgeOutput.receive(10)).isNull();

PollingConsumer pollableBridge = this.context.getBean("pollableBridge", PollingConsumer.class);
PeriodicTrigger periodicTrigger = TestUtils.getPropertyValue(pollableBridge, "trigger", PeriodicTrigger.class);
assertThat(periodicTrigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(1));

this.pollableBridgeInput.send(testMessage);
receive = this.pollableBridgeOutput.receive(10_000);
assertThat(receive).isNotNull();
assertThat(testMessage).isSameAs(receive);
assertThat(this.pollableBridgeOutput.receive(10)).isNull();


assertThatExceptionOfType(MessageDeliveryException.class)
.isThrownBy(() -> this.metaBridgeInput.send(testMessage))
.withMessageContaining("Dispatcher has no subscribers");
Expand Down Expand Up @@ -948,7 +951,8 @@ public PollableChannel pollableBridgeInput() {


@Bean
@BridgeFrom(value = "pollableBridgeInput", poller = @Poller(fixedDelay = "1000"))
@BridgeFrom(value = "pollableBridgeInput", poller = @Poller)
@EndpointId("pollableBridge")
public QueueChannel pollableBridgeOutput() {
return new QueueChannel();
}
Expand Down
2 changes: 2 additions & 0 deletions src/reference/antora/modules/ROOT/pages/channel-adapter.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ See also xref:channel-adapter.adoc#channel-adapter-expressions-and-scripts[Chann
NOTE: If no poller is provided, then a single default poller must be registered within the context.
See xref:endpoint.adoc#endpoint-namespace[Endpoint Namespace Support] for more detail.

NOTE: The default trigger for polling endpoint is a `PeriodicTrigger` instance with a 1 second fixed delay period.

[IMPORTANT]
.Important: Poller Configuration
=====
Expand Down
3 changes: 2 additions & 1 deletion src/reference/antora/modules/ROOT/pages/endpoint.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ PollingConsumer consumer = new PollingConsumer(channel, exampleHandler);
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].

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

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

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

NOTE: The default trigger for polling endpoint is a `PeriodicTrigger` instance with a 1 second fixed delay period.

In addition to the trigger, you can specify two other polling-related configuration properties: `maxMessagesPerPoll` and `receiveTimeout`.
The following example shows how to set these two properties:

Expand Down
3 changes: 3 additions & 0 deletions src/reference/antora/modules/ROOT/pages/whats-new.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ See xref:gateway.adoc#gateway-no-response[Gateway Behavior When No response Arri
- The `LockRegistry` provides template-like API to execute provided task while locked.
See xref:distributed-locks.adoc[Distributed Locks] for more information.

- The default trigger for polling endpoint is now a `PeriodicTrigger` instance with a 1 second fixed delay period; previously, the default was 10 milliseconds.
See xref:endpoint.adoc#endpoint-pollingconsumer[Polling Consumer] for more information.

[[x6.2-websockets]]
=== WebSockets Changes

Expand Down