public abstract class AbstractMessageChannelBinder<C extends ConsumerProperties,P extends ProducerProperties,D> extends AbstractBinder<org.springframework.messaging.MessageChannel,C,P>
AbstractBinder
that serves as base class for MessageChannel
binders. Implementors must implement the following methods:
AbstractBinder.JavaClassMimeTypeConversion
Modifier and Type | Field and Description |
---|---|
protected static org.springframework.expression.ExpressionParser |
EXPRESSION_PARSER |
logger
Constructor and Description |
---|
AbstractMessageChannelBinder(boolean supportsHeadersNatively,
String[] headersToEmbed) |
Modifier and Type | Method and Description |
---|---|
protected void |
afterUnbindConsumer(String destination,
String group,
C consumerProperties)
Invoked after the unbinding of a consumer.
|
protected void |
afterUnbindProducer(String destination,
P producerProperties)
Invoked after the unbinding of a producer.
|
protected abstract D |
createConsumerDestinationIfNecessary(String name,
String group,
C properties)
Creates the middleware destination the consumer will start to consume data from.
|
protected abstract org.springframework.integration.core.MessageProducer |
createConsumerEndpoint(String name,
String group,
D destination,
C properties)
Creates
MessageProducer that receives data from the consumer destination. |
protected abstract void |
createProducerDestinationIfNecessary(String name,
P properties)
Creates target destinations for outbound channels.
|
protected abstract org.springframework.messaging.MessageHandler |
createProducerMessageHandler(String destination,
P producerProperties)
Creates a
MessageHandler with the ability to send data to the
target middleware. |
Binding<org.springframework.messaging.MessageChannel> |
doBindConsumer(String name,
String group,
org.springframework.messaging.MessageChannel inputChannel,
C properties)
Binds an inbound channel to a given destination.
|
Binding<org.springframework.messaging.MessageChannel> |
doBindProducer(String destination,
org.springframework.messaging.MessageChannel outputChannel,
P producerProperties)
Binds an outbound channel to a given destination.
|
afterPropertiesSet, applyPrefix, bindConsumer, bindProducer, buildPartitionRoutingExpression, buildRetryTemplate, constructDLQName, getApplicationContext, getBeanFactory, groupedName, onInit, setApplicationContext, setCodec, setIntegrationEvaluationContext
protected static final org.springframework.expression.ExpressionParser EXPRESSION_PARSER
public AbstractMessageChannelBinder(boolean supportsHeadersNatively, String[] headersToEmbed)
public final Binding<org.springframework.messaging.MessageChannel> doBindProducer(String destination, org.springframework.messaging.MessageChannel outputChannel, P producerProperties) throws BinderException
createProducerDestinationIfNecessary(String, ProducerProperties)
and createProducerMessageHandler(String, ProducerProperties)
for
handling the middleware specific logic. If the returned producer message handler is an
InitializingBean
then InitializingBean.afterPropertiesSet()
will be
called on it. Similarly, if the returned producer message handler endpoint is a
Lifecycle
, then Lifecycle.start()
will be called on it.doBindProducer
in class AbstractBinder<org.springframework.messaging.MessageChannel,C extends ConsumerProperties,P extends ProducerProperties>
destination
- the name of the destinationoutputChannel
- the channel to be boundproducerProperties
- the ProducerProperties
of the bindingBinderException
- on internal errors during bindingprotected abstract void createProducerDestinationIfNecessary(String name, P properties)
name
- the name of the producer destinationproperties
- producer propertiesprotected abstract org.springframework.messaging.MessageHandler createProducerMessageHandler(String destination, P producerProperties) throws Exception
MessageHandler
with the ability to send data to the
target middleware. If the returned instance is also a Lifecycle
,
it will be stopped automatically by the binder.
In order to be fully compliant, the MessageHandler
of the binder
must observe the following headers:
BinderHeaders.PARTITION_HEADER
- indicates the target
partition where the message must be sentdestination
- the name of the target destinationproducerProperties
- the producer propertiesException
protected void afterUnbindProducer(String destination, P producerProperties)
destination
- the bound destinationproducerProperties
- the producer propertiespublic final Binding<org.springframework.messaging.MessageChannel> doBindConsumer(String name, String group, org.springframework.messaging.MessageChannel inputChannel, C properties) throws BinderException
createConsumerDestinationIfNecessary(String, String, ConsumerProperties)
and createConsumerEndpoint(String, String, Object, ConsumerProperties)
for handling middleware-specific logic. If the returned consumer endpoint is an
InitializingBean
then InitializingBean.afterPropertiesSet()
will be
called on it. Similarly, if the returned consumer endpoint is a Lifecycle
,
then Lifecycle.start()
will be called on it.doBindConsumer
in class AbstractBinder<org.springframework.messaging.MessageChannel,C extends ConsumerProperties,P extends ProducerProperties>
name
- the name of the destinationgroup
- the consumer groupinputChannel
- the channel to be boundproperties
- the ConsumerProperties
of the bindingBinderException
- on internal errors during bindingprotected abstract D createConsumerDestinationIfNecessary(String name, String group, C properties)
name
- the name of the destinationgroup
- the consumer groupproperties
- consumer propertiesprotected abstract org.springframework.integration.core.MessageProducer createConsumerEndpoint(String name, String group, D destination, C properties)
MessageProducer
that receives data from the consumer destination.
will be started and stopped by the binder.name
- the name of the target destinationgroup
- the consumer groupdestination
- reference to the consumer destinationproperties
- the consumer propertiesprotected void afterUnbindConsumer(String destination, String group, C consumerProperties)
destination
- the consumer destinationgroup
- the consumer groupconsumerProperties
- the consumer propertiesCopyright © 2016 Pivotal Software, Inc.. All rights reserved.