GH-1433 Added docs for scheduled task for PollableMessageSource

This commit is contained in:
Oleg Zhurakousky
2019-02-26 18:52:48 +01:00
parent 7a7488a959
commit e594070b40
2 changed files with 15 additions and 1 deletions

View File

@@ -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.