|
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.SingleConnectionFactory
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
public class CachingConnectionFactory
NOTE: this ConnectionFactory implementation is considered experimental at this stage. There are concerns to be
addressed in relation to the statefulness of channels. Therefore, we recommend using SingleConnectionFactory
for now.
A ConnectionFactory
implementation that returns the same Connections from all SingleConnectionFactory.createConnection()
calls, and ignores calls to Connection.close()
and caches
Channel
.
By default, only one single Session 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.SingleConnectionFactory |
---|
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(String hostName)
Create a new CachingConnectionFactory given a host name. |
Method Summary | |
---|---|
protected ChannelProxy |
getCachedChannelProxy(Connection connection,
LinkedList<ChannelProxy> channelList,
boolean transactional)
|
protected com.rabbitmq.client.Channel |
getChannel(Connection connection,
boolean transactional)
|
int |
getChannelCacheSize()
|
void |
resetConnection()
Reset the Channel cache and underlying shared Connection, to be reinitialized on next access. |
void |
setChannelCacheSize(int sessionCacheSize)
|
String |
toString()
|
Methods inherited from class org.springframework.amqp.rabbit.connection.SingleConnectionFactory |
---|
closeConnection, createConnection, destroy, doCreateConnection, getHost, getPort, getSharedConnectionProxy, getVirtualHost, initConnection, prepareConnection, setPassword, setPort, setUsername, setVirtualHost |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.beans.factory.DisposableBean |
---|
destroy |
Constructor Detail |
---|
public CachingConnectionFactory()
public 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()
protected com.rabbitmq.client.Channel getChannel(Connection connection, boolean transactional) throws IOException
getChannel
in class SingleConnectionFactory
IOException
protected ChannelProxy getCachedChannelProxy(Connection connection, LinkedList<ChannelProxy> channelList, boolean transactional)
public void resetConnection()
resetConnection
in class SingleConnectionFactory
public String toString()
toString
in class SingleConnectionFactory
|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |