GH-1433 Added docs for scheduled task for PollableMessageSource

Resolves #1433
This commit is contained in:
Oleg Zhurakousky
2019-02-26 18:55:07 +01:00
parent 20d755fe2a
commit 3ce9a38242

View File

@@ -756,6 +756,22 @@ 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.