Class AbstractMessageChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- ApplicationContextAware,- ExpressionCapable,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageChannel,- InterceptableChannel
- Direct Known Subclasses:
- AbstractAmqpChannel,- AbstractJmsChannel,- AbstractKafkaChannel,- AbstractPollableChannel,- AbstractSubscribableChannel,- FluxMessageChannel,- SubscribableRedisChannel,- ZeroMqChannel
@IntegrationManagedResource
public abstract class AbstractMessageChannel
extends IntegrationObjectSupport
implements MessageChannel, TrackableComponent, InterceptableChannel, IntegrationManagement, IntegrationPattern
Base class for 
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.- Author:
- Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Christian Tzolov
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static classA convenience wrapper class for the list of ChannelInterceptors.Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final AbstractMessageChannel.ChannelInterceptorListprotected final Set<MeterFacade>Fields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.messaging.MessageChannelINDEFINITE_TIMEOUT
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddInterceptor(int index, ChannelInterceptor interceptor) Add a channel interceptor to the specified index of the list.voidaddInterceptor(ChannelInterceptor interceptor) Add a channel interceptor to the end of the list.voiddestroy()protected abstract booleanSubclasses must implement this method.Subclasses may implement this method to provide component type information.Returns the fully qualified channel name including the application context id, if available.Exposes the interceptor list instance for subclasses.Return a pattern type this component implements.Return a read-only list of the configured interceptors.protected MetricsCaptorReturn the overrides.booleanReturn whether logging is enabled.booleanTrue if this implementation is going to deal with a registry other than theObservationRegistry.NOOPinstance.protected voidonInit()Subclasses may implement this for initialization logic.voidregisterMetricsCaptor(MetricsCaptor metricsCaptorToRegister) Inject aMetricsCaptor.voidregisterObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) Inject anObservationRegistry.removeInterceptor(int index) booleanremoveInterceptor(ChannelInterceptor interceptor) booleanSend a message on this channel.booleanSend a message on this channel.voidsetDatatypes(Class<?>... datatypes) Specify the Message payload datatype(s) supported by this channel.voidsetInterceptors(List<ChannelInterceptor> interceptors) Set the list of channel interceptors.voidsetLoggingEnabled(boolean loggingEnabled) Enable logging or not.voidsetMessageConverter(MessageConverter messageConverter) Specify theMessageConverterto use when trying to convert to one of this channel's supported datatypes (in order) for a Message whose payload does not already match.voidsetObservationConvention(MessageSenderObservationConvention observationConvention) voidsetShouldTrack(boolean shouldTrack) Methods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetManagedName, getManagedType, getThisAs, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
interceptors
- 
meters
 
- 
- 
Constructor Details- 
AbstractMessageChannelpublic AbstractMessageChannel()
 
- 
- 
Method Details- 
getComponentTypeDescription copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
- getComponentTypein interface- NamedComponent
- Overrides:
- getComponentTypein class- IntegrationObjectSupport
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
setShouldTrackpublic void setShouldTrack(boolean shouldTrack) - Specified by:
- setShouldTrackin interface- TrackableComponent
 
- 
registerMetricsCaptorDescription copied from interface:IntegrationManagementInject aMetricsCaptor. Ignored ifObservationRegistryis provided.- Specified by:
- registerMetricsCaptorin interface- IntegrationManagement
- Parameters:
- metricsCaptorToRegister- the captor.
- See Also:
 
- 
getMetricsCaptor
- 
isLoggingEnabledpublic boolean isLoggingEnabled()Description copied from interface:IntegrationManagementReturn whether logging is enabled.- Specified by:
- isLoggingEnabledin interface- IntegrationManagement
- Returns:
- true if enabled.
 
- 
setLoggingEnabledpublic void setLoggingEnabled(boolean loggingEnabled) Description copied from interface:IntegrationManagementEnable logging or not.- Specified by:
- setLoggingEnabledin interface- IntegrationManagement
- Parameters:
- loggingEnabled- false to disable.
 
- 
setDatatypesSpecify the Message payload datatype(s) supported by this channel. If a payload type does not match directly, but the 'conversionService' is available, then type conversion will be attempted in the order of the elements provided in this array.If this property is not set explicitly, any Message payload type will be accepted. - Parameters:
- datatypes- The supported data types.
- See Also:
 
- 
setInterceptorsSet the list of channel interceptors. This will clear any existing interceptors.- Specified by:
- setInterceptorsin interface- InterceptableChannel
- Parameters:
- interceptors- The list of interceptors.
 
- 
addInterceptorAdd a channel interceptor to the end of the list.- Specified by:
- addInterceptorin interface- InterceptableChannel
- Parameters:
- interceptor- The interceptor.
 
- 
addInterceptorAdd a channel interceptor to the specified index of the list.- Specified by:
- addInterceptorin interface- InterceptableChannel
- Parameters:
- index- The index to add interceptor.
- interceptor- The interceptor.
 
- 
setMessageConverterSpecify theMessageConverterto 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 aMessage, the inbound headers will be copied; if the returned object is aMessage, it is expected that the converter will have fully populated the headers; no further action is performed by the channel. Ifnullis returned, conversion to the next datatype (if any) will be attempted. Defaults to aDefaultDatatypeChannelMessageConverter.- Parameters:
- messageConverter- The message converter.
 
- 
setObservationConventionpublic void setObservationConvention(@Nullable MessageSenderObservationConvention observationConvention) 
- 
getInterceptorsReturn a read-only list of the configured interceptors.- Specified by:
- getInterceptorsin interface- InterceptableChannel
 
- 
removeInterceptor- Specified by:
- removeInterceptorin interface- InterceptableChannel
 
- 
removeInterceptor- Specified by:
- removeInterceptorin interface- InterceptableChannel
 
- 
getIChannelInterceptorListExposes the interceptor list instance for subclasses.- Returns:
- The channel interceptor list.
 
- 
getOverridesDescription copied from interface:IntegrationManagementReturn the overrides.- Specified by:
- getOverridesin interface- IntegrationManagement
- Returns:
- the overrides.
 
- 
registerObservationRegistrypublic void registerObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) Description copied from interface:IntegrationManagementInject anObservationRegistry. If provided, theMetricsCaptoris ignored. The meters capturing has to be configured as anObservationHandleron the providedObservationRegistry.- Specified by:
- registerObservationRegistryin interface- IntegrationManagement
- Parameters:
- observationRegistry- the- ObservationRegistryto expose observations from the component.
- See Also:
 
- 
isObservedpublic boolean isObserved()Description copied from interface:IntegrationManagementTrue if this implementation is going to deal with a registry other than theObservationRegistry.NOOPinstance.- Specified by:
- isObservedin interface- IntegrationManagement
- Returns:
- true if this implementation is going to deal with a registry other than the ObservationRegistry.NOOPinstance.
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
getFullChannelNameReturns the fully qualified channel name including the application context id, if available.- Returns:
- The name.
 
- 
sendSend a message on this channel. If the channel is at capacity, this method will block until either space becomes available or the sending thread is interrupted.- Specified by:
- sendin interface- MessageChannel
- Parameters:
- message- the Message to send
- Returns:
- trueif the message is sent successfully or- falseif the sending thread is interrupted.
 
- 
sendSend a message on this channel. If the channel is at capacity, this method will block until either the timeout occurs or the sending thread is interrupted. If the specified timeout is 0, the method will return immediately. If less than zero, it will block indefinitely (seesend(Message)).- Specified by:
- sendin interface- MessageChannel
- Parameters:
- messageArg- the Message to send
- timeout- the timeout in milliseconds
- Returns:
- trueif the message is sent successfully,- falseif the message cannot be sent within the allotted time or the sending thread is interrupted.
 
- 
doSendSubclasses must implement this method. A non-negative timeout indicates how long to wait if the channel is at capacity (if the value is 0, it must return immediately with or without success). A negative timeout value indicates that the method should block until either the message is accepted or the blocking thread is interrupted.- Parameters:
- message- The message.
- timeout- The timeout.
- Returns:
- true if the sendwas successful.
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Specified by:
- destroyin interface- IntegrationManagement
 
 
-