Example usage for org.springframework.messaging.handler.invocation.reactive ChannelSendOperator ChannelSendOperator

List of usage examples for org.springframework.messaging.handler.invocation.reactive ChannelSendOperator ChannelSendOperator

Introduction

In this page you can find the example usage for org.springframework.messaging.handler.invocation.reactive ChannelSendOperator ChannelSendOperator.

Prototype

public ChannelSendOperator(Publisher<? extends T> source,
            Function<Publisher<T>, Publisher<Void>> writeFunction) 

Source Link

Usage

From source file:org.springframework.messaging.handler.invocation.reactive.AbstractEncoderMethodReturnValueHandler.java

@Override
public Mono<Void> handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
        Message<?> message) {/*from   w  w  w  .  j  a v  a  2 s. c  o  m*/

    if (returnValue == null) {
        return handleNoContent(returnType, message);
    }

    DataBufferFactory bufferFactory = (DataBufferFactory) message.getHeaders().getOrDefault(
            HandlerMethodReturnValueHandler.DATA_BUFFER_FACTORY_HEADER, this.defaultBufferFactory);

    MimeType mimeType = (MimeType) message.getHeaders().get(MessageHeaders.CONTENT_TYPE);
    Flux<DataBuffer> encodedContent = encodeContent(returnValue, returnType, bufferFactory, mimeType,
            Collections.emptyMap());

    return new ChannelSendOperator<>(encodedContent,
            publisher -> handleEncodedContent(Flux.from(publisher), returnType, message));
}