GH-1433 Added docs for scheduled task for PollableMessageSource
This commit is contained in:
@@ -726,6 +726,20 @@ public ApplicationRunner poller(PollableMessageSource destIn, MessageChannel des
|
||||
}
|
||||
----
|
||||
|
||||
A less manual and more Spring-like alternative would be to configure a scheduled task bean. For example,
|
||||
|
||||
[source,java]
|
||||
----
|
||||
|
||||
@Scheduled(fixedDelay = 5_000)
|
||||
public void poll() {
|
||||
System.out.println("Polling...");
|
||||
this.source.poll(m -> {
|
||||
System.out.println(m.getPayload());
|
||||
|
||||
}, new ParameterizedTypeReference<Foo>() { });
|
||||
}
|
||||
----
|
||||
The `PollableMessageSource.poll()` method takes a `MessageHandler` argument (often a lambda expression, as shown here).
|
||||
It returns `true` if the message was received and successfully processed.
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -28,7 +28,7 @@
|
||||
<reactor.version>Californium-RELEASE</reactor.version>
|
||||
<kryo-shaded.version>3.0.3</kryo-shaded.version>
|
||||
<objenesis.version>2.1</objenesis.version>
|
||||
<spring-cloud-function.version>2.0.1.RELEASE
|
||||
<spring-cloud-function.version>2.0.2.BUILD-SNAPSHOT
|
||||
</spring-cloud-function.version>
|
||||
|
||||
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
|
||||
|
||||
Reference in New Issue
Block a user