Class DefaultHeaderChannelRegistry
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.DefaultHeaderChannelRegistry
- All Implemented Interfaces:
- Runnable,- Aware,- BeanFactoryAware,- BeanNameAware,- InitializingBean,- ApplicationContextAware,- Lifecycle,- ExpressionCapable,- HeaderChannelRegistry,- NamedComponent,- ManageableLifecycle
public class DefaultHeaderChannelRegistry
extends IntegrationObjectSupport
implements HeaderChannelRegistry, ManageableLifecycle, Runnable
Converts a channel to a name, retaining a reference to the channel keyed by the name.
 Allows a downstream
 
BeanFactoryChannelResolver
 to find the channel by name
 in the event that the flow serialized the message at some point.
 Channels are expired after a configurable delay (60 seconds by default).
 The actual average expiry time will be 1.5x the delay.- Since:
- 3.0
- Author:
- Gary Russell, Artem Bilan, Trung Pham, Christian Tzolov
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static final record
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final Map<String, DefaultHeaderChannelRegistry.MessageChannelWrapper> protected static final AtomicLongprotected final StringFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, logger
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct a registry with the default delay for channel expiry.DefaultHeaderChannelRegistry(long reaperDelay) Construct a registry with the provided delay (milliseconds) for channel expiry.
- 
Method SummaryModifier and TypeMethodDescriptionchannelNameToChannel(String name) Converts the channel name back to aMessageChannel(if it is registered).channelToChannelName(Object channel) Converts the channel to a name (String).channelToChannelName(Object channel, long timeToLive) Converts the channel to a name (String).final longbooleanprotected voidonInit()Subclasses may implement this for initialization logic.voidrun()voidCancel the scheduled reap task and run immediately; then reschedule.final voidsetReaperDelay(long reaperDelay) Set the reaper delay.voidsetRemoveOnGet(boolean removeOnGet) Set to true to immediately remove the channel mapping whenchannelNameToChannel(String)is invoked.final intsize()voidstart()voidstop()voidMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
- 
Field Details- 
id
- 
channels
- 
uuid
 
- 
- 
Constructor Details- 
DefaultHeaderChannelRegistrypublic DefaultHeaderChannelRegistry()Construct a registry with the default delay for channel expiry.
- 
DefaultHeaderChannelRegistrypublic DefaultHeaderChannelRegistry(long reaperDelay) Construct a registry with the provided delay (milliseconds) for channel expiry.- Parameters:
- reaperDelay- the delay in milliseconds.
 
 
- 
- 
Method Details- 
setReaperDelaypublic final void setReaperDelay(long reaperDelay) Set the reaper delay.- Parameters:
- reaperDelay- the delay in milliseconds.
 
- 
getReaperDelaypublic final long getReaperDelay()
- 
setRemoveOnGetpublic void setRemoveOnGet(boolean removeOnGet) Set to true to immediately remove the channel mapping whenchannelNameToChannel(String)is invoked.- Parameters:
- removeOnGet- true to remove immediately, default false.
- Since:
- 4.1
 
- 
sizepublic final int size()- Specified by:
- sizein interface- HeaderChannelRegistry
- Returns:
- the current size of the registry
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- IntegrationObjectSupport
 
- 
startpublic void start()- Specified by:
- startin interface- Lifecycle
- Specified by:
- startin interface- ManageableLifecycle
 
- 
stoppublic void stop()- Specified by:
- stopin interface- Lifecycle
- Specified by:
- stopin interface- ManageableLifecycle
 
- 
stop
- 
isRunningpublic boolean isRunning()- Specified by:
- isRunningin interface- Lifecycle
- Specified by:
- isRunningin interface- ManageableLifecycle
 
- 
channelToChannelNameDescription copied from interface:HeaderChannelRegistryConverts the channel to a name (String). If the channel is not aMessageChannel, it is returned unchanged.- Specified by:
- channelToChannelNamein interface- HeaderChannelRegistry
- Parameters:
- channel- The channel.
- Returns:
- The channel name, or the channel if it is not a MessageChannel.
 
- 
channelToChannelNameDescription copied from interface:HeaderChannelRegistryConverts the channel to a name (String). If the channel is not aMessageChannel, it is returned unchanged.- Specified by:
- channelToChannelNamein interface- HeaderChannelRegistry
- Parameters:
- channel- The channel.
- timeToLive- How long (ms) at a minimum, the channel mapping should remain in the registry.
- Returns:
- The channel name, or the channel if it is not a MessageChannel.
 
- 
channelNameToChannelDescription copied from interface:HeaderChannelRegistryConverts the channel name back to aMessageChannel(if it is registered).- Specified by:
- channelNameToChannelin interface- HeaderChannelRegistry
- Parameters:
- name- The name of the channel.
- Returns:
- The channel, or null if there is no channel registered with the name.
 
- 
runReaperpublic void runReaper()Cancel the scheduled reap task and run immediately; then reschedule.- Specified by:
- runReaperin interface- HeaderChannelRegistry
 
- 
run
 
-