Example usage for org.springframework.messaging.support ExecutorSubscribableChannel getInterceptors

List of usage examples for org.springframework.messaging.support ExecutorSubscribableChannel getInterceptors

Introduction

In this page you can find the example usage for org.springframework.messaging.support ExecutorSubscribableChannel getInterceptors.

Prototype

@Override
    public List<ChannelInterceptor> getInterceptors() 

Source Link

Usage

From source file:org.springframework.messaging.simp.broker.OrderedMessageSender.java

/**
 * Install or remove an {@link ExecutorChannelInterceptor} that invokes a
 * completion task once the message is handled.
 * @param channel the channel to configure
 * @param preservePublishOrder whether preserve order is on or off based on
 * which an interceptor is either added or removed.
 *//*from   ww  w .j  av  a 2s  .  com*/
static void configureOutboundChannel(MessageChannel channel, boolean preservePublishOrder) {
    if (preservePublishOrder) {
        Assert.isInstanceOf(ExecutorSubscribableChannel.class, channel,
                "An ExecutorSubscribableChannel is required for `preservePublishOrder`");
        ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel;
        if (execChannel.getInterceptors().stream().noneMatch(i -> i instanceof CallbackInterceptor)) {
            execChannel.addInterceptor(0, new CallbackInterceptor());
        }
    } else if (channel instanceof ExecutorSubscribableChannel) {
        ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel;
        execChannel.getInterceptors().stream().filter(i -> i instanceof CallbackInterceptor).findFirst()
                .map(execChannel::removeInterceptor);

    }
}