Example usage for org.springframework.integration.channel.interceptor WireTap WireTap

List of usage examples for org.springframework.integration.channel.interceptor WireTap WireTap

Introduction

In this page you can find the example usage for org.springframework.integration.channel.interceptor WireTap WireTap.

Prototype

public WireTap(String channelName) 

Source Link

Document

Create a new wire tap based on the MessageChannel name and with no MessageSelector .

Usage

From source file:xolpoc.plugins.StreamPlugin.java

private MessageChannel tapOutputChannel(MessageChannel tapChannel, ChannelInterceptorAware outputChannel) {
    outputChannel.addInterceptor(new WireTap(tapChannel));
    return tapChannel;
}

From source file:com.nayidisha.slowglow.config.SpringMessagingConfig.java

/**
 * Interceptor intercepts messages on channels before the message go to the
 * designated channel endpoint// ww w  .j  a  v a  2s  .co  m
 *
 * preSend is invoked before a message is sent and returns the message that
 * will be sent to the channel when the method returns. If the method
 * returns null, nothing is sent. This allows the implementation to control
 * what gets sent to the channel, effectively filtering the messages.
 * 
 * postSend is invoked after an attempt to send the message has been made.
 * It indicates whether the attempt was successful through the boolean flag
 * it passes as an argument. This allows the implementation to monitor the
 * message flow and learn which messages are sent and which ones fail.
 * 
 * preReceive applies only if the channel is pollable. Its invoked when a
 * component calls receive() on the channel, but before a Message is
 * actually read from that channel. It allows implementers to decide whether
 * the channel can return a message to the caller.
 * 
 * postReceive, like preReceive, applies only to pollable channels. Its
 * invoked after a message is read from a channel but before its returned
 * to the component that called receive(). If it returns null, then no
 * message is received. This allows the implementer to control what, if
 * anything, is actually received by the poller.
 * 
 * @return
 */
@Bean(name = "wireTap")
public ChannelInterceptor wireTap() {
    WireTap interceptor = new WireTap(webSocketInputChannel());

    return interceptor;
}

From source file:org.springframework.xd.dirt.plugins.stream.StreamPlugin.java

private void bindProducers(Module module, MessageBus bus) {
    DeploymentMetadata md = module.getDeploymentMetadata();
    MessageChannel channel = module.getComponent("output", MessageChannel.class);
    if (channel != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("binding output channel [" + md.getOutputChannelName() + "] for " + module);
        }/*from   w w  w  .  j  av a  2s.  c  o m*/
        if (isChannelPubSub(md.getOutputChannelName())) {
            bus.bindPubSubProducer(md.getOutputChannelName(), channel);
        } else {
            bus.bindProducer(md.getOutputChannelName(), channel, md.isAliasedOutput());
        }

        // TODO remove this once addInterceptor is an interface method in SI
        Object rawChannel = extractTarget(channel);

        // Create the tap channel now for possible future use (tap:mystream.mymodule)
        if (rawChannel instanceof AbstractMessageChannel) {
            String tapChannelName = getTapChannelName(module);
            DirectChannel tapChannel = new DirectChannel();
            tapChannel.setBeanName(tapChannelName + ".tap.bridge");
            ((AbstractMessageChannel) rawChannel).addInterceptor(new WireTap(tapChannel));
            bus.bindPubSubProducer(tapChannelName, tapChannel);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("output channel is not an AbstractMessageChannel. Tap will not be created.");
            }
        }
    }
}