Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,15 @@ private void bindFunctionToDestinations(BindableProxyFactory bindableProxyFactor
if (!(resultPublishers instanceof Iterable)) {
resultPublishers = Collections.singletonList(resultPublishers);
}
Iterator<String> outputBindingIter = outputBindingNames.iterator();
long outputCount = StreamSupport.stream(((Iterable) resultPublishers).spliterator(), false).count();
if (!CollectionUtils.isEmpty(outputBindingNames) && outputCount != outputBindingNames.size()) {
throw new IllegalStateException("Reactive function '" + functionDefinition
+ "' produced " + outputCount + " output publisher(s) but " + outputBindingNames.size()
+ " output binding(s) are configured " + outputBindingNames
+ ". Each configured output binding must have a corresponding publisher; "
+ "return a Tuple of Flux/Publisher when binding multiple outputs.");
}
Iterator<String> outputBindingIter = outputBindingNames.iterator();

((Iterable) resultPublishers).forEach(publisher -> {
Flux flux = Flux.from((Publisher) publisher);
Expand All @@ -584,7 +591,7 @@ private void bindFunctionToDestinations(BindableProxyFactory bindableProxyFactor
}
if (message instanceof Message m && m.getHeaders().get("spring.cloud.stream.sendto.destination") != null) {
String destinationName = (String) m.getHeaders().get("spring.cloud.stream.sendto.destination");
ProducerProperties producerProperties = this.serviceProperties.getBindings().get(outputBindingNames.iterator().next()).getProducer();
ProducerProperties producerProperties = this.serviceProperties.getBindings().get(outputBinding).getProducer();
MessageChannel dynamicChannel = streamBridge.resolveDestination(destinationName, producerProperties, null);
if (logger.isInfoEnabled()) {
logger.info("Output message is sent to '" + destinationName + "' destination");
Expand Down