@IntegrationManagedResource public abstract class AbstractMessageChannel extends IntegrationObjectSupport implements MessageChannel, TrackableComponent, ChannelInterceptorAware, MessageChannelMetrics, ConfigurableMetricsAware<AbstractMessageChannelMetrics>
MessageChannel implementations providing common
properties such as the channel name. Also provides the common functionality
for sending and receiving Messages including the invocation
of any ChannelInterceptors.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractMessageChannel.ChannelInterceptorList
A convenience wrapper class for the list of ChannelInterceptors.
|
IntegrationManagement.ManagementOverrides| Modifier and Type | Field and Description |
|---|---|
protected AbstractMessageChannel.ChannelInterceptorList |
interceptors |
protected Set<MeterFacade> |
meters |
EXPRESSION_PARSER, loggerINDEFINITE_TIMEOUTMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME| Constructor and Description |
|---|
AbstractMessageChannel() |
| Modifier and Type | Method and Description |
|---|---|
void |
addInterceptor(ChannelInterceptor interceptor)
Add a channel interceptor to the end of the list.
|
void |
addInterceptor(int index,
ChannelInterceptor interceptor)
Add a channel interceptor to the specified index of the list.
|
void |
configureMetrics(AbstractMessageChannelMetrics metrics) |
void |
destroy() |
protected abstract boolean |
doSend(Message<?> message,
long timeout)
Subclasses must implement this method.
|
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
Statistics |
getErrorRate() |
String |
getFullChannelName()
Returns the fully qualified channel name including the application context
id, if available.
|
protected AbstractMessageChannel.ChannelInterceptorList |
getIChannelInterceptorList()
Exposes the interceptor list instance for subclasses.
|
List<ChannelInterceptor> |
getInterceptors()
Return a read-only list of the configured interceptors.
|
double |
getMaxSendDuration() |
double |
getMeanErrorRate() |
double |
getMeanErrorRatio() |
double |
getMeanSendDuration() |
double |
getMeanSendRate() |
protected AbstractMessageChannelMetrics |
getMetrics() |
protected MetricsCaptor |
getMetricsCaptor() |
double |
getMinSendDuration() |
IntegrationManagement.ManagementOverrides |
getOverrides()
Return the overrides.
|
int |
getSendCount() |
long |
getSendCountLong() |
Statistics |
getSendDuration() |
int |
getSendErrorCount() |
long |
getSendErrorCountLong() |
Statistics |
getSendRate() |
double |
getStandardDeviationSendDuration() |
double |
getTimeSinceLastSend() |
boolean |
isCountsEnabled() |
boolean |
isLoggingEnabled() |
boolean |
isStatsEnabled() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
Inject a
MetricsCaptor |
boolean |
removeInterceptor(ChannelInterceptor interceptor) |
ChannelInterceptor |
removeInterceptor(int index) |
void |
reset() |
boolean |
send(Message<?> message)
Send a message on this channel.
|
boolean |
send(Message<?> messageArg,
long timeout)
Send a message on this channel.
|
void |
setCountsEnabled(boolean countsEnabled) |
void |
setDatatypes(Class<?>... datatypes)
Specify the Message payload datatype(s) supported by this channel.
|
void |
setInterceptors(List<ChannelInterceptor> interceptors)
Set the list of channel interceptors.
|
void |
setLoggingEnabled(boolean loggingEnabled) |
void |
setMessageConverter(MessageConverter messageConverter)
Specify the
MessageConverter to use when trying to convert to
one of this channel's supported datatypes (in order) for a Message whose payload
does not already match. |
void |
setShouldTrack(boolean shouldTrack) |
void |
setStatsEnabled(boolean statsEnabled) |
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, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBeanName, getComponentNamegetChannelInterceptorssendCount, sendErrorCountprotected final AbstractMessageChannel.ChannelInterceptorList interceptors
protected final Set<MeterFacade> meters
public String getComponentType()
IntegrationObjectSupportgetComponentType in interface NamedComponentgetComponentType in class IntegrationObjectSupportpublic void setShouldTrack(boolean shouldTrack)
setShouldTrack in interface TrackableComponentpublic void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
IntegrationManagementMetricsCaptorregisterMetricsCaptor in interface IntegrationManagementmetricsCaptorToRegister - the captor.@Nullable protected MetricsCaptor getMetricsCaptor()
public void setCountsEnabled(boolean countsEnabled)
setCountsEnabled in interface IntegrationManagementpublic boolean isCountsEnabled()
isCountsEnabled in interface IntegrationManagementpublic void setStatsEnabled(boolean statsEnabled)
setStatsEnabled in interface IntegrationStatsManagementpublic boolean isStatsEnabled()
isStatsEnabled in interface IntegrationStatsManagementpublic boolean isLoggingEnabled()
isLoggingEnabled in interface IntegrationManagementpublic void setLoggingEnabled(boolean loggingEnabled)
setLoggingEnabled in interface IntegrationManagementprotected AbstractMessageChannelMetrics getMetrics()
public void configureMetrics(AbstractMessageChannelMetrics metrics)
configureMetrics in interface ConfigurableMetricsAware<AbstractMessageChannelMetrics>public void setDatatypes(Class<?>... datatypes)
If this property is not set explicitly, any Message payload type will be accepted.
datatypes - The supported data types.setMessageConverter(MessageConverter)public void setInterceptors(List<ChannelInterceptor> interceptors)
setInterceptors in interface InterceptableChannelinterceptors - The list of interceptors.public void addInterceptor(ChannelInterceptor interceptor)
addInterceptor in interface InterceptableChannelinterceptor - The interceptor.public void addInterceptor(int index,
ChannelInterceptor interceptor)
addInterceptor in interface InterceptableChannelindex - The index to add interceptor.interceptor - The interceptor.public void setMessageConverter(MessageConverter messageConverter)
MessageConverter to use when trying to convert to
one of this channel's supported datatypes (in order) for a Message whose payload
does not already match.
Note: only the MessageConverter.fromMessage(Message, Class)
method is used. If the returned object is not a Message, the inbound
headers will be copied; if the returned object is a Message, it is
expected that the converter will have fully populated the headers; no
further action is performed by the channel. If null is returned,
conversion to the next datatype (if any) will be attempted.
Defaults to a
DefaultDatatypeChannelMessageConverter.
messageConverter - The message converter.public List<ChannelInterceptor> getInterceptors()
getInterceptors in interface InterceptableChannelpublic boolean removeInterceptor(ChannelInterceptor interceptor)
removeInterceptor in interface InterceptableChannel@Nullable public ChannelInterceptor removeInterceptor(int index)
removeInterceptor in interface InterceptableChannelprotected AbstractMessageChannel.ChannelInterceptorList getIChannelInterceptorList()
public void reset()
reset in interface IntegrationManagementpublic int getSendCount()
getSendCount in interface MessageChannelMetricspublic long getSendCountLong()
getSendCountLong in interface MessageChannelMetricspublic int getSendErrorCount()
getSendErrorCount in interface MessageChannelMetricspublic long getSendErrorCountLong()
getSendErrorCountLong in interface MessageChannelMetricspublic double getTimeSinceLastSend()
getTimeSinceLastSend in interface MessageChannelMetricspublic double getMeanSendRate()
getMeanSendRate in interface MessageChannelMetricspublic double getMeanErrorRate()
getMeanErrorRate in interface MessageChannelMetricspublic double getMeanErrorRatio()
getMeanErrorRatio in interface MessageChannelMetricspublic double getMeanSendDuration()
getMeanSendDuration in interface MessageChannelMetricspublic double getMinSendDuration()
getMinSendDuration in interface MessageChannelMetricspublic double getMaxSendDuration()
getMaxSendDuration in interface MessageChannelMetricspublic double getStandardDeviationSendDuration()
getStandardDeviationSendDuration in interface MessageChannelMetricspublic Statistics getSendDuration()
getSendDuration in interface MessageChannelMetricspublic Statistics getSendRate()
getSendRate in interface MessageChannelMetricspublic Statistics getErrorRate()
getErrorRate in interface MessageChannelMetricspublic IntegrationManagement.ManagementOverrides getOverrides()
IntegrationManagementgetOverrides in interface IntegrationManagementprotected void onInit()
IntegrationObjectSupportonInit in class IntegrationObjectSupportpublic String getFullChannelName()
public boolean send(Message<?> message)
send in interface MessageChannelmessage - the Message to sendtrue if the message is sent successfully or
false if the sending thread is interrupted.public boolean send(Message<?> messageArg, long timeout)
send(Message)).send in interface MessageChannelmessageArg - the Message to sendtimeout - the timeout in millisecondstrue if the message is sent successfully,
false if the message cannot be sent within the allotted
time or the sending thread is interrupted.protected abstract boolean doSend(Message<?> message, long timeout)
message - The message.timeout - The timeout.public void destroy()
destroy in interface DisposableBeandestroy in interface IntegrationManagement