Class MessageStreamResolverUtils

java.lang.Object
org.axonframework.messaging.core.annotation.MessageStreamResolverUtils

@Internal public class MessageStreamResolverUtils extends Object
Utility class that can resolve the result of any MessageHandler into the expected corresponding MessageStream.

Whether a returned Iterable represents several results or one result that happens to be a collection cannot be derived from the value itself. Callers therefore choose the cardinality up front: resolveToStream(Object, MessageTypeResolver) spreads an Iterable over as many Messages as it holds elements, while resolveToSingleStream(Object, MessageTypeResolver) carries it as the Message.payload() of a single Message. Both unwrap asynchronous containers such as CompletableFuture first, so that List<T> and CompletableFuture<List<T>> yield the same cardinality.

This utility class currently has a drawback, which is that it only takes the "top level" type into account. Differently put, if we receive a Mono<Message> as the given result, we will push that Message through the given typeResolver and make it the Message.payload().

This is a known limitation that will be supported in due time.

Since:
5.0.0
Author:
Simon Zambrovski, Steven van Beelen