java.lang.Object
org.springframework.integration.channel.interceptor.WireTap
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.Lifecycle, VetoCapableInterceptor, ManageableLifecycle, org.springframework.messaging.support.ChannelInterceptor

@ManagedResource
public class WireTap
extends java.lang.Object
implements org.springframework.messaging.support.ChannelInterceptor, ManageableLifecycle, VetoCapableInterceptor, org.springframework.beans.factory.BeanFactoryAware
A ChannelInterceptor that publishes a copy of the intercepted message to a secondary target while still sending the original message to the main channel.
  • Constructor Summary

    Constructors 
    Constructor Description
    WireTap​(java.lang.String channelName)
    Create a new wire tap based on the MessageChannel name and with no MessageSelector.
    WireTap​(java.lang.String channelName, MessageSelector selector)
    Create a new wire tap with the provided MessageSelector.
    WireTap​(org.springframework.messaging.MessageChannel channel)
    Create a new wire tap with no MessageSelector.
    WireTap​(org.springframework.messaging.MessageChannel channel, MessageSelector selector)
    Create a new wire tap with the provided MessageSelector.
  • Method Summary

    Modifier and Type Method Description
    boolean isRunning()
    Check whether the wire tap is currently running.
    org.springframework.messaging.Message<?> preSend​(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)
    Intercept the Message and, if accepted by the MessageSelector, send it to the secondary target.
    void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory)  
    void setTimeout​(long timeout)
    Specify the timeout value for sending to the intercepting target.
    boolean shouldIntercept​(java.lang.String beanName, org.springframework.messaging.support.InterceptableChannel channel)  
    void start()
    Restart the wire tap if it has been stopped.
    void stop()
    Stop the wire tap.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.messaging.support.ChannelInterceptor

    afterReceiveCompletion, afterSendCompletion, postReceive, postSend, preReceive
  • Constructor Details

    • WireTap

      public WireTap​(org.springframework.messaging.MessageChannel channel)
      Create a new wire tap with no MessageSelector.
      Parameters:
      channel - the MessageChannel to which intercepted messages will be sent
    • WireTap

      public WireTap​(org.springframework.messaging.MessageChannel channel, MessageSelector selector)
      Create a new wire tap with the provided MessageSelector.
      Parameters:
      channel - the channel to which intercepted messages will be sent
      selector - the selector that must accept a message for it to be sent to the intercepting channel
    • WireTap

      public WireTap​(java.lang.String channelName)
      Create a new wire tap based on the MessageChannel name and with no MessageSelector.
      Parameters:
      channelName - the name of the target MessageChannel to which intercepted messages will be sent
      Since:
      4.3
    • WireTap

      public WireTap​(java.lang.String channelName, MessageSelector selector)
      Create a new wire tap with the provided MessageSelector.
      Parameters:
      channelName - the name of the target MessageChannel to which intercepted messages will be sent.
      selector - the selector that must accept a message for it to be sent to the intercepting channel
      Since:
      4.3
  • Method Details

    • setTimeout

      public void setTimeout​(long timeout)
      Specify the timeout value for sending to the intercepting target.
      Parameters:
      timeout - the timeout in milliseconds
    • setBeanFactory

      public void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • isRunning

      @ManagedAttribute public boolean isRunning()
      Check whether the wire tap is currently running.
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface ManageableLifecycle
    • start

      @ManagedOperation public void start()
      Restart the wire tap if it has been stopped. It is running by default.
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Specified by:
      start in interface ManageableLifecycle
    • stop

      @ManagedOperation public void stop()
      Stop the wire tap. To restart, invoke start().
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Specified by:
      stop in interface ManageableLifecycle
    • preSend

      public org.springframework.messaging.Message<?> preSend​(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel)
      Intercept the Message and, if accepted by the MessageSelector, send it to the secondary target. If this wire tap's MessageSelector is null, it will accept all messages.
      Specified by:
      preSend in interface org.springframework.messaging.support.ChannelInterceptor
    • shouldIntercept

      public boolean shouldIntercept​(java.lang.String beanName, org.springframework.messaging.support.InterceptableChannel channel)
      Specified by:
      shouldIntercept in interface VetoCapableInterceptor
      Parameters:
      beanName - The channel name.
      channel - The channel that is about to be intercepted.
      Returns:
      false if the intercept wishes to veto the interception.