Class WireTap
java.lang.Object
org.springframework.integration.channel.interceptor.WireTap
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,Lifecycle
,VetoCapableInterceptor
,ManageableLifecycle
,ChannelInterceptor
@ManagedResource public class WireTap extends Object implements ChannelInterceptor, ManageableLifecycle, VetoCapableInterceptor, 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.- Author:
- Mark Fisher, Gary Russell, Artem Bilan
-
Constructor Summary
Constructors Constructor Description WireTap(String channelName)
Create 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(MessageChannel channel)
Create a new wire tap with noMessageSelector
.WireTap(MessageChannel channel, MessageSelector selector)
Create a new wire tap with the providedMessageSelector
. -
Method Summary
Modifier and Type Method Description boolean
isRunning()
Check whether the wire tap is currently running.Message<?>
preSend(Message<?> message, MessageChannel channel)
Intercept the Message and, if accepted by theMessageSelector
, send it to the secondary target.void
setBeanFactory(BeanFactory beanFactory)
void
setTimeout(long timeout)
Specify the timeout value for sending to the intercepting target.boolean
shouldIntercept(String beanName, 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
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
- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Throws:
BeansException
-
isRunning
Check whether the wire tap is currently running.- Specified by:
isRunning
in interfaceLifecycle
- Specified by:
isRunning
in interfaceManageableLifecycle
-
start
Restart the wire tap if it has been stopped. It is running by default.- Specified by:
start
in interfaceLifecycle
- Specified by:
start
in interfaceManageableLifecycle
-
stop
Stop the wire tap. To restart, invokestart()
.- Specified by:
stop
in interfaceLifecycle
- Specified by:
stop
in interfaceManageableLifecycle
-
preSend
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 interfaceChannelInterceptor
-
shouldIntercept
- 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.
-