Class RabbitGatewaySupport
java.lang.Object
org.springframework.amqp.rabbit.core.RabbitGatewaySupport
- All Implemented Interfaces:
InitializingBean
Convenient 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.
- Author:
- Mark Pollack, Gary Russell
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
protected RabbitTemplate
createRabbitTemplate
(ConnectionFactory connectionFactory) Create a RabbitTemplate for the given ConnectionFactory.final ConnectionFactory
final RabbitOperations
protected void
Subclasses can override this for custom initialization behavior.final void
setConnectionFactory
(ConnectionFactory connectionFactory) Set the Rabbit connection factory to be used by the gateway.final void
setRabbitOperations
(RabbitOperations rabbitOperations) Set theRabbitOperations
for the gateway.
-
Field Details
-
logger
Logger available to subclasses.
-
-
Constructor Details
-
RabbitGatewaySupport
public RabbitGatewaySupport()
-
-
Method Details
-
setConnectionFactory
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
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:
-
getConnectionFactory
- Returns:
- The Rabbit ConnectionFactory used by the gateway.
-
setRabbitOperations
Set theRabbitOperations
for the gateway.- Parameters:
rabbitOperations
- The Rabbit operations.- See Also:
-
getRabbitOperations
- Returns:
- The
RabbitOperations
for the gateway.
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
IllegalArgumentException
BeanInitializationException
-
initGateway
protected void initGateway()Subclasses can override this for custom initialization behavior. Gets called after population of this instance's bean properties.
-