GH-1956 Add support for PollableSource in functional programing model

This feature effectively provides identical path to create PollableSource as it was in annotation-based programming model.
However, unlike creating and  providing binding intreface all that is required from user is 'spring.cloud.stream.pollable-source' property

Resolves #1956
This commit is contained in:
Oleg Zhurakousky
2020-09-22 20:32:06 +02:00
parent 66eaef460d
commit 9a906e7369
6 changed files with 134 additions and 18 deletions

View File

@@ -1242,21 +1242,18 @@ support.
===== Overview
When using polled consumers, you poll the `PollableMessageSource` on demand.
Consider the following example of a polled consumer:
To define binding for polled consumer you need to provide `spring.cloud.stream.pollable-source` property.
[source,java]
Consider the following example of a polled consumer binding:
[source,text]
----
public interface PolledConsumer {
@Input
PollableMessageSource destIn();
@Output
MessageChannel destOut();
}
--spring.cloud.stream.pollable-source=myDestination
----
The pollable-source name `myDestination` in the preceding example will result in `myDestination-in-0` binding name to stay
consistent with functional programming model.
Given the polled consumer in the preceding example, you might use it as follows:
[source,java]
@@ -1348,6 +1345,7 @@ boolean result = pollableSource.poll(received -> {
}, new ParameterizedTypeReference<Map<String, Foo>>() {});
----
[[polled-errors]]
===== Handling Errors