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 booleanisRunning()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.voidsetBeanFactory(BeanFactory beanFactory)voidsetTimeout(long timeout)Specify the timeout value for sending to the intercepting target.booleanshouldIntercept(String beanName, 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
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:
setBeanFactoryin interfaceBeanFactoryAware- Throws:
BeansException
-
isRunning
Check whether the wire tap is currently running.- Specified by:
isRunningin interfaceLifecycle- Specified by:
isRunningin interfaceManageableLifecycle
-
start
Restart the wire tap if it has been stopped. It is running by default.- Specified by:
startin interfaceLifecycle- Specified by:
startin interfaceManageableLifecycle
-
stop
Stop the wire tap. To restart, invokestart().- Specified by:
stopin interfaceLifecycle- Specified by:
stopin interfaceManageableLifecycle
-
preSend
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 interfaceChannelInterceptor
-
shouldIntercept
- 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.
-