GH-8625: Add Duration support for <poller> (#8627)

* GH-8625: Add Duration support for `<poller>`

Fixes https://github.com/spring-projects/spring-integration/issues/8625

The duration can be represented in a ISO 8601 format, e.g. `PT10S`, `P1D` etc.
The `<poller>` and `@Poller` don't support such a format.

* Introduce a `PeriodicTriggerFactoryBean` to accept string values for
trigger options and parse them manually before creating the target `PeriodicTrigger`
* Use this `PeriodicTriggerFactoryBean` in the `PollerParser` and `AbstractMethodAnnotationPostProcessor`
where we parse options for the `PeriodicTrigger`
* Modify tests to ensure that feature works
* Document the duration option
* Add more cross-links into polling docs
* Fix typos in the affected doc files
* Add `-parameters` for compiler options since SF 6.1 does not support `-debug` anymore
for method parameter names discovery

* Fix typos

Co-authored-by: Gary Russell <grussell@vmware.com>

---------

Co-authored-by: Gary Russell <grussell@vmware.com>
This commit is contained in:
Artem Bilan
2023-05-22 11:47:08 -04:00
committed by GitHub
parent ba417de680
commit c70d7a6688
13 changed files with 210 additions and 84 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@@ -16,7 +16,7 @@
package org.springframework.integration.config.xml;
import java.time.temporal.ChronoUnit;
import java.time.Duration;
import java.util.HashMap;
import org.aopalliance.aop.Advice;
@@ -112,7 +112,9 @@ public class PollerParserTests {
PollerMetadata metadata = (PollerMetadata) poller;
assertThat(metadata.getReceiveTimeout()).isEqualTo(1234);
PeriodicTrigger trigger = (PeriodicTrigger) metadata.getTrigger();
assertThat(TestUtils.getPropertyValue(trigger, "chronoUnit")).isEqualTo(ChronoUnit.SECONDS);
assertThat(trigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(5));
assertThat(trigger.isFixedRate()).isTrue();
assertThat(trigger.getInitialDelayDuration()).isEqualTo(Duration.ofSeconds(45));
context.close();
}
@@ -123,7 +125,7 @@ public class PollerParserTests {
Object poller = context.getBean("poller");
assertThat(poller).isNotNull();
PollerMetadata metadata = (PollerMetadata) poller;
assertThat(metadata.getTrigger() instanceof TestTrigger).isTrue();
assertThat(metadata.getTrigger()).isInstanceOf(TestTrigger.class);
context.close();
}

View File

@@ -15,6 +15,6 @@
<beans:prop key="seconds">SECONDS</beans:prop>
</util:properties>
<poller id="poller" receive-timeout="1234" fixed-rate="5" time-unit="${seconds}"/>
<poller id="poller" receive-timeout="1234" fixed-rate="5" time-unit="${seconds}" initial-delay="PT45S"/>
</beans:beans>

View File

@@ -1,5 +1,5 @@
message.history.tracked.components=input, publishedChannel, annotationTestService*
poller.maxMessagesPerPoll=10
poller.interval=100
poller.interval=PT0.1S
poller.receiveTimeout=10000
global.wireTap.pattern=input