Class WireTap
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 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
ConstructorsConstructorDescriptionCreate a new wire tap based on the MessageChannel name and with noMessageSelector.WireTap(String channelName, MessageSelector selector) Create a new wire tap with the providedMessageSelector.WireTap(org.springframework.messaging.MessageChannel channel) Create a new wire tap with noMessageSelector.WireTap(org.springframework.messaging.MessageChannel channel, MessageSelector selector) Create a new wire tap with the providedMessageSelector. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck 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 theMessageSelector, send it to the secondary target.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsetTimeout(long timeout) Specify the timeout value for sending to the intercepting target.booleanshouldIntercept(String beanName, org.springframework.messaging.support.InterceptableChannel channel) voidstart()Restart the wire tap if it has been stopped.voidstop()Stop the wire tap.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 noMessageSelector.- Parameters:
channel- the MessageChannel to which intercepted messages will be sent
-
WireTap
Create a new wire tap with the providedMessageSelector.- Parameters:
channel- the channel to which intercepted messages will be sentselector- the selector that must accept a message for it to be sent to the intercepting channel
-
WireTap
Create a new wire tap based on the MessageChannel name and with noMessageSelector.- Parameters:
channelName- the name of the target MessageChannel to which intercepted messages will be sent- Since:
- 4.3
-
WireTap
Create a new wire tap with the providedMessageSelector.- 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:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
isRunning
@ManagedAttribute public boolean isRunning()Check whether the wire tap is currently running.- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle- Specified by:
isRunningin interfaceManageableLifecycle
-
start
@ManagedOperation public void start()Restart the wire tap if it has been stopped. It is running by default.- Specified by:
startin interfaceorg.springframework.context.Lifecycle- Specified by:
startin interfaceManageableLifecycle
-
stop
@ManagedOperation public void stop()Stop the wire tap. To restart, invokestart().- Specified by:
stopin interfaceorg.springframework.context.Lifecycle- Specified by:
stopin interfaceManageableLifecycle
-
preSend
public org.springframework.messaging.Message<?> preSend(org.springframework.messaging.Message<?> message, org.springframework.messaging.MessageChannel channel) Intercept the Message and, if accepted by theMessageSelector, send it to the secondary target. If this wire tap'sMessageSelectorisnull, it will accept all messages.- Specified by:
preSendin interfaceorg.springframework.messaging.support.ChannelInterceptor
-
shouldIntercept
public boolean shouldIntercept(String beanName, org.springframework.messaging.support.InterceptableChannel channel) - Specified by:
shouldInterceptin interfaceVetoCapableInterceptor- Parameters:
beanName- The channel name.channel- The channel that is about to be intercepted.- Returns:
- false if the intercept wishes to veto the interception.
-