Class AbstractAmqpChannel
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.channel.AbstractMessageChannel
org.springframework.integration.amqp.channel.AbstractAmqpChannel
- All Implemented Interfaces:
ConnectionListener
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,ExpressionCapable
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageChannel
,InterceptableChannel
- Direct Known Subclasses:
PointToPointSubscribableAmqpChannel
,PollableAmqpChannel
,PublishSubscribeAmqpChannel
public abstract class AbstractAmqpChannel
extends AbstractMessageChannel
implements ConnectionListener
The base
AbstractMessageChannel
implementation for AMQP.- Since:
- 2.1
- Author:
- Mark Fisher, Artem Bilan, Gary Russell
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.integration.channel.AbstractMessageChannel
AbstractMessageChannel.ChannelInterceptorList
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Fields inherited from class org.springframework.integration.channel.AbstractMessageChannel
interceptors, meters
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
protected abstract void
protected boolean
Subclasses must implement this method.protected AmqpAdmin
getAdmin()
protected AmqpTemplate
protected ConnectionFactory
protected String
Subclasses may override this method to return an Exchange name.protected AmqpHeaderMapper
protected RabbitTemplate
protected String
Subclasses may override this method to return a routing key.protected boolean
boolean
Return whether logging is enabled.void
onCreate
(Connection connection) protected void
onInit()
Subclasses may implement this for initialization logic.protected final void
protected final void
setConnectionFactory
(ConnectionFactory connectionFactory) void
setDefaultDeliveryMode
(MessageDeliveryMode defaultDeliveryMode) Set the delivery mode to use if the message has no "amqp_deliveryMode" header and the message property was not set by theMessagePropertiesConverter
.void
setExtractPayload
(boolean extractPayload) Set to true to extract the payload and map the headers; otherwise the entire message is converted and sent.void
setHeadersMappedLast
(boolean headersMappedLast) When mapping headers for the outbound message, determine whether the headers are mapped before the message is converted, or afterward.void
setLoggingEnabled
(boolean loggingEnabled) Enable logging or not.Methods inherited from class org.springframework.integration.channel.AbstractMessageChannel
addInterceptor, addInterceptor, getComponentType, getFullChannelName, getIChannelInterceptorList, getIntegrationPatternType, getInterceptors, getMetricsCaptor, getOverrides, isObserved, registerMetricsCaptor, registerObservationRegistry, removeInterceptor, removeInterceptor, send, send, setDatatypes, setInterceptors, setMessageConverter, setObservationConvention, setShouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.amqp.rabbit.connection.ConnectionListener
onClose, onFailed, onShutDown
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getManagedName, getManagedType, getThisAs, setManagedName, setManagedType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Method Details
-
isLoggingEnabled
public boolean isLoggingEnabled()Description copied from interface:IntegrationManagement
Return whether logging is enabled.- Specified by:
isLoggingEnabled
in interfaceIntegrationManagement
- Overrides:
isLoggingEnabled
in classAbstractMessageChannel
- Returns:
- true if enabled.
-
setLoggingEnabled
public void setLoggingEnabled(boolean loggingEnabled) Description copied from interface:IntegrationManagement
Enable logging or not.- Specified by:
setLoggingEnabled
in interfaceIntegrationManagement
- Overrides:
setLoggingEnabled
in classAbstractMessageChannel
- Parameters:
loggingEnabled
- false to disable.
-
setDefaultDeliveryMode
Set the delivery mode to use if the message has no "amqp_deliveryMode" header and the message property was not set by theMessagePropertiesConverter
.- Parameters:
defaultDeliveryMode
- the default delivery mode.- Since:
- 4.3
-
setExtractPayload
public void setExtractPayload(boolean extractPayload) Set to true to extract the payload and map the headers; otherwise the entire message is converted and sent. Default false.- Parameters:
extractPayload
- true to extract and map.- Since:
- 4.3
-
isExtractPayload
protected boolean isExtractPayload()- Returns:
- the extract payload.
- Since:
- 4.3
- See Also:
-
setHeadersMappedLast
public void setHeadersMappedLast(boolean headersMappedLast) When mapping headers for the outbound message, determine whether the headers are mapped before the message is converted, or afterward. This only affects headers that might be added by the message converter. When false, the converter's headers win; when true, any headers added by the converter will be overridden (if the source message has a header that maps to those headers). You might wish to set this to true, for example, when using aSimpleMessageConverter
with a String payload that contains json; the converter will set the content type totext/plain
which can be overridden toapplication/json
by setting theAmqpHeaders.CONTENT_TYPE
message header. Only applies whenextractPayload
is true. Default: false.- Parameters:
headersMappedLast
- true if headers are mapped after conversion.- Since:
- 5.0
-
getExchangeName
Subclasses may override this method to return an Exchange name. By default, Messages will be sent to the no-name Direct Exchange.- Returns:
- The exchange name.
-
getRoutingKey
Subclasses may override this method to return a routing key. By default, there will be no routing key (empty string).- Returns:
- The routing key.
-
getInboundHeaderMapper
-
getAmqpTemplate
-
getRabbitTemplate
-
setAdmin
-
setConnectionFactory
-
getAdmin
-
getConnectionFactory
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classAbstractMessageChannel
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceIntegrationManagement
- Overrides:
destroy
in classAbstractMessageChannel
-
doSend
Description copied from class:AbstractMessageChannel
Subclasses 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.- Specified by:
doSend
in classAbstractMessageChannel
- Parameters:
message
- The message.timeout
- The timeout.- Returns:
- true if the
send
was successful.
-
onCreate
- Specified by:
onCreate
in interfaceConnectionListener
-
doDeclares
protected abstract void doDeclares()
-