@IntegrationManagedResource public abstract class AbstractMessageChannel extends IntegrationObjectSupport implements MessageChannel, TrackableComponent, InterceptableChannel, IntegrationManagement, IntegrationPattern
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, logger
INDEFINITE_TIMEOUT
METER_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 |
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.
|
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.
|
IntegrationPatternType |
getIntegrationPatternType()
Return a pattern type this component implements.
|
List<ChannelInterceptor> |
getInterceptors()
Return a read-only list of the configured interceptors.
|
protected MetricsCaptor |
getMetricsCaptor() |
IntegrationManagement.ManagementOverrides |
getOverrides()
Return the overrides.
|
boolean |
isLoggingEnabled()
Return whether logging is enabled.
|
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) |
boolean |
send(Message<?> message)
Send a message on this channel.
|
boolean |
send(Message<?> messageArg,
long timeout)
Send a message on this channel.
|
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)
Enable logging or not.
|
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) |
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
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
getBeanName, getComponentName
protected final AbstractMessageChannel.ChannelInterceptorList interceptors
protected final Set<MeterFacade> meters
public String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
public IntegrationPatternType getIntegrationPatternType()
IntegrationPattern
getIntegrationPatternType
in interface IntegrationPattern
IntegrationPatternType
this component implements.public void setShouldTrack(boolean shouldTrack)
setShouldTrack
in interface TrackableComponent
public void registerMetricsCaptor(MetricsCaptor metricsCaptorToRegister)
IntegrationManagement
MetricsCaptor
registerMetricsCaptor
in interface IntegrationManagement
metricsCaptorToRegister
- the captor.@Nullable protected MetricsCaptor getMetricsCaptor()
public boolean isLoggingEnabled()
IntegrationManagement
isLoggingEnabled
in interface IntegrationManagement
public void setLoggingEnabled(boolean loggingEnabled)
IntegrationManagement
setLoggingEnabled
in interface IntegrationManagement
loggingEnabled
- dalse to disable.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 InterceptableChannel
interceptors
- The list of interceptors.public void addInterceptor(ChannelInterceptor interceptor)
addInterceptor
in interface InterceptableChannel
interceptor
- The interceptor.public void addInterceptor(int index, ChannelInterceptor interceptor)
addInterceptor
in interface InterceptableChannel
index
- 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 InterceptableChannel
public boolean removeInterceptor(ChannelInterceptor interceptor)
removeInterceptor
in interface InterceptableChannel
@Nullable public ChannelInterceptor removeInterceptor(int index)
removeInterceptor
in interface InterceptableChannel
protected AbstractMessageChannel.ChannelInterceptorList getIChannelInterceptorList()
public IntegrationManagement.ManagementOverrides getOverrides()
IntegrationManagement
getOverrides
in interface IntegrationManagement
protected void onInit()
IntegrationObjectSupport
onInit
in class IntegrationObjectSupport
public String getFullChannelName()
public boolean send(Message<?> message)
send
in interface MessageChannel
message
- 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 MessageChannel
messageArg
- 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 DisposableBean
destroy
in interface IntegrationManagement