Class RabbitGatewaySupport
- java.lang.Object
-
- org.springframework.amqp.rabbit.core.RabbitGatewaySupport
-
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
public class RabbitGatewaySupport extends java.lang.Object implements org.springframework.beans.factory.InitializingBeanConvenient super class for application classes that need RabbitMQ access.Requires a ConnectionFactory or a RabbitTemplate instance to be set. It will create its own RabbitTemplate if a ConnectionFactory is passed in. A custom RabbitTemplate instance can be created for a given ConnectionFactory through overriding the
createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory)method.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.LogloggerLogger available to subclasses.
-
Constructor Summary
Constructors Constructor Description RabbitGatewaySupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected RabbitTemplatecreateRabbitTemplate(ConnectionFactory connectionFactory)Create a RabbitTemplate for the given ConnectionFactory.ConnectionFactorygetConnectionFactory()RabbitOperationsgetRabbitOperations()protected voidinitGateway()Subclasses can override this for custom initialization behavior.voidsetConnectionFactory(ConnectionFactory connectionFactory)Set the Rabbit connection factory to be used by the gateway.voidsetRabbitOperations(RabbitOperations rabbitOperations)Set theRabbitOperationsfor the gateway.
-
-
-
Method Detail
-
setConnectionFactory
public final void setConnectionFactory(ConnectionFactory connectionFactory)
Set the Rabbit connection factory to be used by the gateway. Will automatically create a RabbitTemplate for the given ConnectionFactory.- Parameters:
connectionFactory- The connection factory.- See Also:
createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory),setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)
-
createRabbitTemplate
protected RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory)
Create a RabbitTemplate for the given ConnectionFactory. Only invoked if populating the gateway with a ConnectionFactory reference.- Parameters:
connectionFactory- the Rabbit ConnectionFactory to create a RabbitTemplate for- Returns:
- the new RabbitTemplate instance
- See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)
-
getConnectionFactory
@Nullable public final ConnectionFactory getConnectionFactory()
- Returns:
- The Rabbit ConnectionFactory used by the gateway.
-
setRabbitOperations
public final void setRabbitOperations(RabbitOperations rabbitOperations)
Set theRabbitOperationsfor the gateway.- Parameters:
rabbitOperations- The Rabbit operations.- See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)
-
getRabbitOperations
public final RabbitOperations getRabbitOperations()
- Returns:
- The
RabbitOperationsfor the gateway.
-
afterPropertiesSet
public final void afterPropertiesSet() throws java.lang.IllegalArgumentException, org.springframework.beans.factory.BeanInitializationException- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
java.lang.IllegalArgumentExceptionorg.springframework.beans.factory.BeanInitializationException
-
initGateway
protected void initGateway()
Subclasses can override this for custom initialization behavior. Gets called after population of this instance's bean properties.
-
-