Class MessageProducerSupport
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
- All Implemented Interfaces:
- Aware,- BeanFactoryAware,- BeanNameAware,- DisposableBean,- InitializingBean,- SmartInitializingSingleton,- ApplicationContextAware,- Lifecycle,- Phased,- SmartLifecycle,- ComponentSourceAware,- ExpressionCapable,- MessageProducer,- IntegrationPattern,- NamedComponent,- IntegrationInboundManagement,- IntegrationManagement,- ManageableLifecycle,- ManageableSmartLifecycle,- TrackableComponent
- Direct Known Subclasses:
- AbstractHazelcastMessageProducer,- AbstractInternetProtocolReceivingChannelAdapter,- AbstractMqttMessageDrivenChannelAdapter,- AbstractXmppConnectionAwareEndpoint,- AmqpInboundChannelAdapter,- DebeziumMessageProducer,- ExpressionMessageProducerSupport,- FileTailingMessageProducerSupport,- HazelcastClusterMonitorMessageProducer,- ImapIdleChannelAdapter,- JmsMessageDrivenEndpoint,- KafkaMessageDrivenChannelAdapter,- MongoDbChangeStreamMessageProducer,- NotificationListeningMessageProducer,- ReactiveMessageSourceProducer,- ReactiveRedisStreamMessageProducer,- RedisInboundChannelAdapter,- RedisQueueMessageDrivenEndpoint,- StompInboundChannelAdapter,- SyslogReceivingChannelAdapterSupport,- TcpReceivingChannelAdapter,- WebSocketInboundChannelAdapter,- ZeroMqMessageProducer
public abstract class MessageProducerSupport
extends AbstractEndpoint
implements MessageProducer, TrackableComponent, SmartInitializingSingleton, IntegrationPattern, IntegrationInboundManagement
A support class for producer endpoints that provides a setter for the
 output channel and a convenience method for sending Messages.
- Author:
- Mark Fisher, Artem Bilan, Gary Russell
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFields inherited from class org.springframework.integration.endpoint.AbstractEndpointlifecycleLockFields 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.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidprotected final ErrorMessagebuildErrorMessage(Message<?> message, Exception exception) Build an error message for the exception and message using the configuredErrorMessageStrategy.protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.Return the error channel (if provided) to which error messages will be routed.protected AttributeAccessorgetErrorMessageAttributes(Message<?> message) Populate anAttributeAccessorto be used when building an error message with theerrorMessageStrategy.protected ErrorMessageStrategyGet anErrorMessageStrategyto use to build an error message when a exception occurs.Return a pattern type this component implements.protected MessagingTemplateReturn the output channel.protected MessageChannelbooleanTrue if this implementation is going to deal with a registry other than theObservationRegistry.NOOPinstance.protected voidonInit()Subclasses may implement this for initialization logic.voidregisterObservationRegistry(io.micrometer.observation.ObservationRegistry observationRegistry) Inject anObservationRegistry.protected final booleansendErrorMessageIfNecessary(Message<?> message, Exception exception) Send an error message based on the exception and message.protected voidsendMessage(Message<?> message) voidsetErrorChannel(MessageChannel errorChannel) voidsetErrorChannelName(String errorChannelName) Set the error channel name.voidsetErrorMessageStrategy(ErrorMessageStrategy errorMessageStrategy) Set anErrorMessageStrategyto use to build an error message when a exception occurs.voidsetObservationConvention(MessageReceiverObservationConvention observationConvention) Set a customMessageReceiverObservationConventionforIntegrationObservation.HANDLER.voidsetOutputChannel(MessageChannel outputChannel) Specify theMessageChannelto which produced Messages should be sent.voidsetOutputChannelName(String outputChannelName) Set the output channel name; overridesoutputChannelif provided.voidsetSendTimeout(long sendTimeout) Configure the default timeout value to use for send operations.voidsetShouldTrack(boolean shouldTrack) protected voidsubscribeToPublisher(org.reactivestreams.Publisher<? extends Message<?>> publisher) Methods inherited from class org.springframework.integration.endpoint.AbstractEndpointdestroy, doStop, getPhase, getRole, isActive, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getComponentType, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, 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.IntegrationManagementdestroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName, getComponentType
- 
Constructor Details- 
MessageProducerSupportprotected MessageProducerSupport()
 
- 
- 
Method Details- 
setOutputChannelDescription copied from interface:MessageProducerSpecify theMessageChannelto which produced Messages should be sent.- Specified by:
- setOutputChannelin interface- MessageProducer
- Parameters:
- outputChannel- The output channel.
 
- 
setOutputChannelNameSet the output channel name; overridesoutputChannelif provided.- Specified by:
- setOutputChannelNamein interface- MessageProducer
- Parameters:
- outputChannelName- the channel name.
- Since:
- 4.3
 
- 
getOutputChannelDescription copied from interface:MessageProducerReturn the output channel.- Specified by:
- getOutputChannelin interface- MessageProducer
- Returns:
- the channel.
 
- 
setErrorChannel
- 
setErrorChannelNameSet the error channel name. If no error channel is provided, this endpoint will propagate Exceptions to the message-driven source. To completely suppress Exceptions, provide a reference to the "nullChannel" here.- Parameters:
- errorChannelName- The error channel bean name.
- Since:
- 4.3
 
- 
getErrorChannelReturn the error channel (if provided) to which error messages will be routed.- Returns:
- the channel or null.
- Since:
- 4.3
 
- 
setSendTimeoutpublic void setSendTimeout(long sendTimeout) Configure the default timeout value to use for send operations. May be overridden for individual messages.- Parameters:
- sendTimeout- the 'send' operation timeout in milliseconds
- See Also:
 
- 
setShouldTrackpublic void setShouldTrack(boolean shouldTrack) - Specified by:
- setShouldTrackin interface- TrackableComponent
 
- 
setErrorMessageStrategySet anErrorMessageStrategyto use to build an error message when a exception occurs. Default is theDefaultErrorMessageStrategy.- Parameters:
- errorMessageStrategy- the- ErrorMessageStrategy.
- Since:
- 4.3.10
 
- 
getErrorMessageStrategyGet anErrorMessageStrategyto use to build an error message when a exception occurs. Default is theDefaultErrorMessageStrategy.- Returns:
- the errorMessageStrategy
- Since:
- 6.0
 
- 
getMessagingTemplate
- 
setObservationConventionpublic void setObservationConvention(@Nullable MessageReceiverObservationConvention observationConvention) Set a customMessageReceiverObservationConventionforIntegrationObservation.HANDLER. Ignored if anObservationRegistryis not configured for this component.- Parameters:
- observationConvention- the- MessageReceiverObservationConventionto use.
- Since:
- 6.0
 
- 
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.
 
- 
getIntegrationPatternTypeDescription copied from interface:IntegrationPatternReturn a pattern type this component implements.- Specified by:
- getIntegrationPatternTypein interface- IntegrationPattern
- Returns:
- the IntegrationPatternTypethis component implements.
 
- 
afterSingletonsInstantiatedpublic void afterSingletonsInstantiated()- Specified by:
- afterSingletonsInstantiatedin interface- SmartInitializingSingleton
 
- 
onInitprotected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
- onInitin class- AbstractEndpoint
 
- 
doStartprotected void doStart()Take no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Specified by:
- doStartin class- AbstractEndpoint
 
- 
doStopprotected void doStop()Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Specified by:
- doStopin class- AbstractEndpoint
 
- 
sendMessage
- 
subscribeToPublisher
- 
sendErrorMessageIfNecessaryprotected final boolean sendErrorMessageIfNecessary(@Nullable Message<?> message, Exception exception) Send an error message based on the exception and message.- Parameters:
- message- the message.
- exception- the exception.
- Returns:
- true if the error channel is available and message sent.
- Since:
- 4.3.10
 
- 
buildErrorMessageBuild an error message for the exception and message using the configuredErrorMessageStrategy.- Parameters:
- message- the message.
- exception- the exception.
- Returns:
- the error message.
- Since:
- 4.3.10
 
- 
getErrorMessageAttributesPopulate anAttributeAccessorto be used when building an error message with theerrorMessageStrategy.- Parameters:
- message- the message.
- Returns:
- the attributes.
- Since:
- 4.3.10
 
- 
getRequiredOutputChannel
 
-