public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHandler implements DiscardingMessageHandler, Lifecycle
MessageSelector
. If and only if
the selector accepts
the Message, it
will be passed to this filter's output channel. Otherwise the message will
either be silently dropped (the default) or will trigger the throwing of a
MessageRejectedException
depending on the value of its
throwExceptionOnRejection
property. If a discard channel is
provided, the rejected Messages will be sent to that channel.AbstractReplyProducingMessageHandler.RequestHandler
IntegrationManagement.ManagementOverrides
messagingTemplate
EXPRESSION_PARSER, logger
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
MessageFilter(MessageSelector selector)
Create a MessageFilter that will delegate to the given
MessageSelector . |
Modifier and Type | Method and Description |
---|---|
protected Object |
doHandleRequestMessage(Message<?> message) |
protected void |
doInit() |
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
MessageChannel |
getDiscardChannel()
Return the discard channel.
|
boolean |
isRunning() |
Object |
postProcess(Message<?> message,
Object result)
Take some further action on the result and/or message.
|
void |
setDiscardChannel(MessageChannel discardChannel)
Specify a channel where rejected Messages should be sent.
|
void |
setDiscardChannelName(String discardChannelName) |
void |
setDiscardWithinAdvice(boolean discardWithinAdvice)
Set to 'true' if you wish the discard processing to occur within any
request handler advice applied to this filter.
|
void |
setThrowExceptionOnRejection(boolean throwExceptionOnRejection)
Specify whether this filter should throw a
MessageRejectedException when its selector does not accept a
Message. |
protected boolean |
shouldCopyRequestHeaders()
Subclasses may override this.
|
void |
start() |
void |
stop() |
doInvokeAdvisedRequestHandler, handleRequestMessage, setPostProcessWithinAdvice
getBeanClassLoader, getRequiresReply, handleMessageInternal, hasAdviceChain, onInit, setAdviceChain, setBeanClassLoader, setRequiresReply
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, shouldSplitOutput, updateNotPropagatedHeaders
configureMetrics, destroy, getActiveCount, getActiveCountLong, getDuration, getErrorCount, getErrorCountLong, getHandleCount, getHandleCountLong, getManagedName, getManagedType, getMaxDuration, getMeanDuration, getMetricsCaptor, getMinDuration, getOrder, getOverrides, getStandardDeviationDuration, handleMessage, isCountsEnabled, isLoggingEnabled, isStatsEnabled, onComplete, onError, onNext, onSubscribe, registerMetricsCaptor, reset, setCountsEnabled, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, setStatsEnabled
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
handleMessage
errorCount, handleCount
getBeanName, getComponentName
public MessageFilter(MessageSelector selector)
MessageSelector
.selector
- The message selector.public void setThrowExceptionOnRejection(boolean throwExceptionOnRejection)
MessageRejectedException
when its selector does not accept a
Message. The default value is false
meaning that rejected
Messages will be quietly dropped or sent to the discard channel if
available. Typically this value would not be true
when
a discard channel is provided, but if so, it will still apply
(in such a case, the Message will be sent to the discard channel,
and then the exception will be thrown).throwExceptionOnRejection
- true if an exception should be thrown.setDiscardChannel(MessageChannel)
public void setDiscardChannel(MessageChannel discardChannel)
discardChannel
- The discard channel.setThrowExceptionOnRejection(boolean)
public void setDiscardChannelName(String discardChannelName)
public void setDiscardWithinAdvice(boolean discardWithinAdvice)
discardWithinAdvice
- true to discard within the advice.public MessageChannel getDiscardChannel()
DiscardingMessageHandler
getDiscardChannel
in interface DiscardingMessageHandler
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class AbstractMessageHandler
protected void doInit()
doInit
in class AbstractReplyProducingMessageHandler
protected Object doHandleRequestMessage(Message<?> message)
doHandleRequestMessage
in class AbstractReplyProducingPostProcessingMessageHandler
public Object postProcess(Message<?> message, Object result)
PostProcessingMessageHandler
postProcess
in interface PostProcessingMessageHandler
message
- The message.result
- The result from AbstractMessageHandler.handleMessageInternal(Message)
.protected boolean shouldCopyRequestHeaders()
AbstractMessageProducingHandler
shouldCopyRequestHeaders
in class AbstractMessageProducingHandler