GH-2143 Add documentation for batch producers

Resolves #2143
This commit is contained in:
Oleg Zhurakousky
2021-05-25 12:42:03 +02:00
parent b2b95dc7d2
commit dadb8af280

View File

@@ -986,6 +986,30 @@ public Function<List<Person>, Person> findFirstPerson() {
}
----
===== Batch Producers
You can also use the concept of batching on the producer side by returning a collection of Messages which effectively provides an
inverse effect where each message in the collection will be sent individually by the binder.
Consider the following function:
[source, java]
----
@Bean
public Function<String, List<Message<String>>> batch() {
return p -> {
List<Message<String>> list = new ArrayList<>();
list.add(MessageBuilder.withPayload(p + ":1").build());
list.add(MessageBuilder.withPayload(p + ":2").build());
list.add(MessageBuilder.withPayload(p + ":3").build());
list.add(MessageBuilder.withPayload(p + ":4").build());
return list;
};
}
----
Each message in the returned list will be sent individually resulting in four messages sent to output destination.
===== Spring Integration flow as functions
When you implement a function, you may have complex requirements that fit the category
of https://www.enterpriseintegrationpatterns.com[Enterprise Integration Patterns] (EIP). These are best handled by using a