Class AbstractBinder<T,C extends ConsumerProperties,P extends ProducerProperties>
java.lang.Object
org.springframework.cloud.stream.binder.AbstractBinder<T,C,P>
- Type Parameters:
T
- outbound bind target classC
- consumer properties classP
- producer properties class
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,Binder<T,
,C, P> org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
AbstractMessageChannelBinder
public abstract class AbstractBinder<T,C extends ConsumerProperties,P extends ProducerProperties>
extends Object
implements org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean, Binder<T,C,P>
Base class for
Binder
implementations.- Author:
- David Turanski, Gary Russell, Ilayaperumal Gopinathan, Mark Fisher, Marius Bogoevici, Soby Chacko, Vinicius Carvalho, Oleg Zhurakousky, Nicolas Homble
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
static String
applyPrefix
(String prefix, String name) For binder implementations that support a prefix, apply the prefix to the name.bindConsumer
(String name, String group, T target, C properties) Bind the target component as a message consumer to the logical entity identified by the name.bindProducer
(String name, T outboundBindTarget, P properties) Bind the target component as a message producer to the logical entity identified by the name.protected org.springframework.retry.support.RetryTemplate
buildRetryTemplate
(ConsumerProperties properties) Create and configure a default retry template unless one has already been provided via @Bean by an application.static String
constructDLQName
(String name) For binder implementations that support dead lettering, construct the name of the dead letter entity for the underlying pipe name.doBindConsumer
(String name, String group, T inputTarget, C properties) doBindProducer
(String name, T outboundBindTarget, P properties) protected org.springframework.context.support.AbstractApplicationContext
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory
protected BindingServiceProperties
Attempts to getBindingServiceProperties
from application context.protected org.springframework.expression.EvaluationContext
protected final String
groupedName
(String name, String group) Construct a name comprised of the name and group.protected void
onInit()
Subclasses may implement this method to perform any necessary initialization.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.cloud.stream.binder.Binder
getBinderIdentity
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AbstractBinder
public AbstractBinder()
-
-
Method Details
-
applyPrefix
For binder implementations that support a prefix, apply the prefix to the name.- Parameters:
prefix
- the prefix.name
- the name.- Returns:
- name with the prefix
-
constructDLQName
For binder implementations that support dead lettering, construct the name of the dead letter entity for the underlying pipe name.- Parameters:
name
- the name.- Returns:
- name with DLQ suffix
-
getApplicationContext
protected org.springframework.context.support.AbstractApplicationContext getApplicationContext() -
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
getBeanFactory
protected org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory() -
getEvaluationContext
protected org.springframework.expression.EvaluationContext getEvaluationContext() -
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
onInit
Subclasses may implement this method to perform any necessary initialization. It will be invoked fromafterPropertiesSet()
which is itselffinal
.- Throws:
Exception
- when init fails
-
bindConsumer
Description copied from interface:Binder
Bind the target component as a message consumer to the logical entity identified by the name.- Specified by:
bindConsumer
in interfaceBinder<T,
C extends ConsumerProperties, P extends ProducerProperties> - Parameters:
name
- the logical identity of the message sourcegroup
- the consumer group to which this consumer belongs - subscriptions are shared among consumers in the same group (anull
or empty String, must be treated as an anonymous group that doesn't share the subscription with any other consumer)target
- the app interface to be bound as a consumerproperties
- the consumer properties- Returns:
- the setup binding
-
doBindConsumer
-
bindProducer
Description copied from interface:Binder
Bind the target component as a message producer to the logical entity identified by the name.- Specified by:
bindProducer
in interfaceBinder<T,
C extends ConsumerProperties, P extends ProducerProperties> - Parameters:
name
- the logical identity of the message targetoutboundBindTarget
- the app interface to be bound as a producerproperties
- the producer properties- Returns:
- the setup binding
-
doBindProducer
-
groupedName
Construct a name comprised of the name and group.- Parameters:
name
- the name.group
- the group.- Returns:
- the constructed name.
-
getBindingServiceProperties
Attempts to getBindingServiceProperties
from application context.- Returns:
- instance of
BindingServiceProperties
or null.
-
buildRetryTemplate
protected org.springframework.retry.support.RetryTemplate buildRetryTemplate(ConsumerProperties properties) Create and configure a default retry template unless one has already been provided via @Bean by an application.- Parameters:
properties
- The properties.- Returns:
- The retry template
-