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
ConstructorDescriptionCreate 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 TypeMethodDescriptionboolean
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 theMessageSelector
, 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
(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 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:
setBeanFactory
in 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:
isRunning
in interfaceorg.springframework.context.Lifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
@ManagedOperation public void start()Restart the wire tap if it has been stopped. It is running by default.- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
@ManagedOperation public void stop()Stop the wire tap. To restart, invokestart()
.- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
- Specified by:
stop
in 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'sMessageSelector
isnull
, it will accept all messages.- Specified by:
preSend
in interfaceorg.springframework.messaging.support.ChannelInterceptor
-
shouldIntercept
public boolean shouldIntercept(String beanName, org.springframework.messaging.support.InterceptableChannel channel) - Specified by:
shouldIntercept
in 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.
-