Class RabbitGatewaySupport
- java.lang.Object
-
- org.springframework.amqp.rabbit.core.RabbitGatewaySupport
-
- All Implemented Interfaces:
InitializingBean
public class RabbitGatewaySupport extends Object implements 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:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)
,setRabbitOperations(org.springframework.amqp.rabbit.core.RabbitOperations)
,createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory)
,RabbitTemplate
-
-
Constructor Summary
Constructors Constructor Description RabbitGatewaySupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
protected RabbitTemplate
createRabbitTemplate(ConnectionFactory connectionFactory)
Create a RabbitTemplate for the given ConnectionFactory.ConnectionFactory
getConnectionFactory()
RabbitOperations
getRabbitOperations()
protected void
initGateway()
Subclasses can override this for custom initialization behavior.void
setConnectionFactory(ConnectionFactory connectionFactory)
Set the Rabbit connection factory to be used by the gateway.void
setRabbitOperations(RabbitOperations rabbitOperations)
Set theRabbitOperations
for the gateway.
-
-
-
Field Detail
-
logger
protected final Log logger
Logger available to subclasses.
-
-
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 theRabbitOperations
for the gateway.- Parameters:
rabbitOperations
- The Rabbit operations.- See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)
-
getRabbitOperations
public final RabbitOperations getRabbitOperations()
- Returns:
- The
RabbitOperations
for the gateway.
-
afterPropertiesSet
public final void afterPropertiesSet() throws IllegalArgumentException, BeanInitializationException
- 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.
-
-