public abstract class AbstractConnectionFactory extends Object implements ConnectionFactory, DisposableBean, BeanNameAware, ApplicationContextAware, ApplicationEventPublisherAware, ApplicationListener<ContextClosedEvent>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CLOSE_TIMEOUT |
protected Log |
logger |
Constructor and Description |
---|
AbstractConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
Create a new AbstractConnectionFactory for the given target ConnectionFactory,
with no publisher connection factory.
|
Modifier and Type | Method and Description |
---|---|
void |
addChannelListener(ChannelListener listener) |
void |
addConnectionListener(ConnectionListener listener) |
void |
clearConnectionListeners() |
protected Connection |
createBareConnection() |
void |
destroy() |
protected ApplicationContext |
getApplicationContext() |
protected ApplicationEventPublisher |
getApplicationEventPublisher() |
protected String |
getBeanName()
Return a bean name of the component or null if not a bean.
|
protected ChannelListener |
getChannelListener()
A composite channel listener to be used by subclasses when creating and closing channels.
|
int |
getCloseTimeout() |
protected ConnectionListener |
getConnectionListener()
A composite connection listener to be used by subclasses when creating and closing connections.
|
protected boolean |
getContextStopped() |
protected String |
getDefaultHostName() |
protected ExecutorService |
getExecutorService() |
String |
getHost() |
int |
getPort() |
ConnectionFactory |
getPublisherConnectionFactory()
Return a separate connection factory for publishers (if implemented).
|
com.rabbitmq.client.ConnectionFactory |
getRabbitConnectionFactory()
Return a reference to the underlying Rabbit Connection factory.
|
String |
getUsername()
Return the user name from the underlying rabbit connection factory.
|
String |
getVirtualHost() |
boolean |
hasPublisherConnectionFactory() |
void |
onApplicationEvent(ContextClosedEvent event) |
boolean |
removeConnectionListener(ConnectionListener listener) |
void |
setAddresses(String addresses)
Set addresses for clustering.
|
void |
setApplicationContext(ApplicationContext applicationContext) |
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setBeanName(String name) |
void |
setChannelListeners(List<? extends ChannelListener> listeners) |
void |
setCloseTimeout(int closeTimeout)
How long to wait (milliseconds) for a response to a connection close
operation from the broker; default 30000 (30 seconds).
|
void |
setConnectionListeners(List<? extends ConnectionListener> listeners) |
void |
setConnectionNameStrategy(ConnectionNameStrategy connectionNameStrategy)
Provide a
ConnectionNameStrategy to build the name for the target RabbitMQ connection. |
void |
setConnectionThreadFactory(ThreadFactory threadFactory)
Set the
ThreadFactory on the underlying rabbit connection factory. |
void |
setConnectionTimeout(int connectionTimeout) |
void |
setExecutor(Executor executor)
Provide an Executor for
use by the Rabbit ConnectionFactory when creating connections.
|
void |
setHost(String host) |
void |
setPassword(String password) |
void |
setPort(int port) |
protected void |
setPublisherConnectionFactory(AbstractConnectionFactory publisherConnectionFactory) |
void |
setRecoveryListener(com.rabbitmq.client.RecoveryListener recoveryListener)
Set a
RecoveryListener that will be added to each connection created. |
void |
setRequestedHeartBeat(int requestedHeartBeat) |
void |
setShuffleAddresses(boolean shuffleAddresses)
When
addresses are provided and there is more than
one, set to true to shuffle the list before opening a new connection so that the
connection to the broker will be attempted in random order. |
void |
setUri(String uri) |
void |
setUri(URI uri) |
void |
setUsername(String username) |
void |
setVirtualHost(String virtualHost) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createConnection, isPublisherConfirms, isPublisherReturns, isSimplePublisherConfirms
public static final int DEFAULT_CLOSE_TIMEOUT
protected final Log logger
public AbstractConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
rabbitConnectionFactory
- the target ConnectionFactoryprotected final void setPublisherConnectionFactory(AbstractConnectionFactory publisherConnectionFactory)
public void setApplicationContext(ApplicationContext applicationContext)
setApplicationContext
in interface ApplicationContextAware
protected ApplicationContext getApplicationContext()
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
protected ApplicationEventPublisher getApplicationEventPublisher()
public void onApplicationEvent(ContextClosedEvent event)
onApplicationEvent
in interface ApplicationListener<ContextClosedEvent>
protected boolean getContextStopped()
public com.rabbitmq.client.ConnectionFactory getRabbitConnectionFactory()
public String getUsername()
getUsername
in interface ConnectionFactory
public void setUsername(String username)
public void setPassword(String password)
public void setHost(String host)
public void setConnectionThreadFactory(ThreadFactory threadFactory)
ThreadFactory
on the underlying rabbit connection factory.threadFactory
- the thread factory.public void setUri(URI uri)
uri
- the URIConnectionFactory.setUri(URI)
public void setUri(String uri)
uri
- the URIConnectionFactory.setUri(String)
public String getHost()
getHost
in interface ConnectionFactory
public void setVirtualHost(String virtualHost)
public String getVirtualHost()
getVirtualHost
in interface ConnectionFactory
public void setPort(int port)
public void setRequestedHeartBeat(int requestedHeartBeat)
public void setConnectionTimeout(int connectionTimeout)
public int getPort()
getPort
in interface ConnectionFactory
public void setAddresses(String addresses)
addresses
- list of addresses with form "host[:port],..."protected ConnectionListener getConnectionListener()
protected ChannelListener getChannelListener()
public void setConnectionListeners(List<? extends ConnectionListener> listeners)
public void addConnectionListener(ConnectionListener listener)
addConnectionListener
in interface ConnectionFactory
public boolean removeConnectionListener(ConnectionListener listener)
removeConnectionListener
in interface ConnectionFactory
public void clearConnectionListeners()
clearConnectionListeners
in interface ConnectionFactory
public void setChannelListeners(List<? extends ChannelListener> listeners)
public void setRecoveryListener(com.rabbitmq.client.RecoveryListener recoveryListener)
RecoveryListener
that will be added to each connection created.recoveryListener
- the listener.public void addChannelListener(ChannelListener listener)
public void setExecutor(Executor executor)
executor
- The executor.@Nullable protected ExecutorService getExecutorService()
public void setCloseTimeout(int closeTimeout)
closeTimeout
- the closeTimeout to set.public int getCloseTimeout()
public void setConnectionNameStrategy(ConnectionNameStrategy connectionNameStrategy)
ConnectionNameStrategy
to build the name for the target RabbitMQ connection.
The beanName
together with a counter is used by default.connectionNameStrategy
- the ConnectionNameStrategy
to use.public void setBeanName(String name)
setBeanName
in interface BeanNameAware
@Nullable protected String getBeanName()
public void setShuffleAddresses(boolean shuffleAddresses)
addresses
are provided and there is more than
one, set to true to shuffle the list before opening a new connection so that the
connection to the broker will be attempted in random order.shuffleAddresses
- true to shuffle the list.Collections.shuffle(List)
public boolean hasPublisherConnectionFactory()
public ConnectionFactory getPublisherConnectionFactory()
ConnectionFactory
getPublisherConnectionFactory
in interface ConnectionFactory
protected final Connection createBareConnection()
protected final String getDefaultHostName()
public void destroy()
destroy
in interface DisposableBean