|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.amqp.rabbit.connection.AbstractConnectionFactory
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
public class CachingConnectionFactory
A ConnectionFactory
implementation that returns the same Connections from all createConnection()
calls, and ignores calls to Connection.close()
and caches
Channel
.
By default, only one Channel will be cached, with further requested Channels being created and disposed on demand.
Consider raising the "channelCacheSize" value
in case of a high-concurrency
environment.
NOTE: This ConnectionFactory requires explicit closing of all Channels obtained form its shared Connection. This is the usual recommendation for native Rabbit access code anyway. However, with this ConnectionFactory, its use is mandatory in order to actually allow for Channel reuse.
Field Summary |
---|
Fields inherited from class org.springframework.amqp.rabbit.connection.AbstractConnectionFactory |
---|
logger |
Constructor Summary | |
---|---|
CachingConnectionFactory()
Create a new CachingConnectionFactory initializing the hostname to be the value returned from InetAddress.getLocalHost(), or "localhost" if getLocalHost() throws an exception. |
|
CachingConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
Create a new CachingConnectionFactory for the given target ConnectionFactory. |
|
CachingConnectionFactory(int port)
Create a new CachingConnectionFactory given a host name. |
|
CachingConnectionFactory(String hostname)
Create a new CachingConnectionFactory given a host name. |
|
CachingConnectionFactory(String hostname,
int port)
Create a new CachingConnectionFactory given a host name. |
Method Summary | |
---|---|
void |
addConnectionListener(ConnectionListener listener)
|
Connection |
createConnection()
|
void |
destroy()
Close the underlying shared connection. |
int |
getChannelCacheSize()
|
protected void |
reset()
Reset the Channel cache and underlying shared Connection, to be reinitialized on next access. |
void |
setChannelCacheSize(int sessionCacheSize)
|
void |
setConnectionListeners(List<? extends ConnectionListener> listeners)
|
String |
toString()
|
Methods inherited from class org.springframework.amqp.rabbit.connection.AbstractConnectionFactory |
---|
addChannelListener, createBareConnection, getChannelListener, getConnectionListener, getDefaultHostName, getHost, getPort, getVirtualHost, setChannelListeners, setHost, setPassword, setPort, setUsername, setVirtualHost |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CachingConnectionFactory()
public CachingConnectionFactory(String hostname, int port)
hostname
- the host name to connect topublic CachingConnectionFactory(int port)
hostName
- the host name to connect topublic CachingConnectionFactory(String hostname)
hostname
- the host name to connect topublic CachingConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
rabbitConnectionFactory
- the target ConnectionFactoryMethod Detail |
---|
public void setChannelCacheSize(int sessionCacheSize)
public int getChannelCacheSize()
public void setConnectionListeners(List<? extends ConnectionListener> listeners)
setConnectionListeners
in class AbstractConnectionFactory
public void addConnectionListener(ConnectionListener listener)
addConnectionListener
in interface ConnectionFactory
addConnectionListener
in class AbstractConnectionFactory
public final Connection createConnection() throws AmqpException
AmqpException
public final void destroy()
As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.
destroy
in interface DisposableBean
destroy
in class AbstractConnectionFactory
protected void reset()
public String toString()
toString
in class Object
|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |