Class PooledChannelConnectionFactory
java.lang.Object
org.springframework.amqp.rabbit.connection.AbstractConnectionFactory
org.springframework.amqp.rabbit.connection.PooledChannelConnectionFactory
- All Implemented Interfaces:
- com.rabbitmq.client.ShutdownListener,- EventListener,- ConnectionFactory,- Aware,- BeanNameAware,- DisposableBean,- ApplicationContextAware,- ApplicationEventPublisherAware,- ApplicationListener<ContextClosedEvent>,- Lifecycle,- Phased,- SmartLifecycle
public class PooledChannelConnectionFactory
extends AbstractConnectionFactory
implements com.rabbitmq.client.ShutdownListener, SmartLifecycle
A very simple connection factory that caches channels using Apache Pool2
 
GenericObjectPools (one for transactional and one for non-transactional
 channels). The pools have default configuration but they can be configured using
 a callback.- Since:
- 2.3
- Author:
- Gary Russell, Leonardo Ferreira, Christian Tzolov
- 
Nested Class SummaryNested classes/interfaces inherited from class org.springframework.amqp.rabbit.connection.AbstractConnectionFactoryAbstractConnectionFactory.AddressShuffleMode, AbstractConnectionFactory.DefaultChannelCloseLogger
- 
Field SummaryFields inherited from class org.springframework.amqp.rabbit.connection.AbstractConnectionFactoryDEFAULT_CLOSE_TIMEOUT, loggerFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionPooledChannelConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory) Construct an instance.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddConnectionListener(ConnectionListener listener) voiddestroy()intgetPhase()booleanbooleanReturn true if simple publisher confirms are enabled.voidClose the connection(s).voidsetPoolConfigurer(BiConsumer<org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel>, Boolean> poolConfigurer) Add a consumer to configure the object pool.voidsetPublisherConnectionFactory(AbstractConnectionFactory publisherConnectionFactory) Set a custom publisher connection factory; the type does not need to be the same as this factory.voidsetSimplePublisherConfirms(boolean simplePublisherConfirms) Enable simple publisher confirms.voidstart()voidstop()Methods inherited from class org.springframework.amqp.rabbit.connection.AbstractConnectionFactoryaddChannelListener, clearConnectionListeners, createBareConnection, doSetPublisherConnectionFactory, getAddresses, getApplicationContext, getApplicationEventPublisher, getBeanName, getChannelListener, getCloseTimeout, getConnectionListener, getConnectionNameStrategy, getContextStopped, getDefaultHostName, getExecutorService, getHost, getPort, getPublisherConnectionFactory, getRabbitConnectionFactory, getUsername, getVirtualHost, hasPublisherConnectionFactory, onApplicationEvent, removeConnectionListener, setAddresses, setAddressResolver, setAddressShuffleMode, setApplicationContext, setApplicationEventPublisher, setBeanName, setChannelListeners, setCloseExceptionLogger, setCloseTimeout, setConnectionCreatingBackOff, setConnectionListeners, setConnectionNameStrategy, setConnectionThreadFactory, setConnectionTimeout, setExecutor, setHost, setPassword, setPort, setRecoveryListener, setRequestedHeartBeat, setUri, setUri, setUsername, setVirtualHost, shutdownCompleted, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListenersupportsAsyncExecutionMethods inherited from interface org.springframework.amqp.rabbit.connection.ConnectionFactoryisPublisherConfirms, isPublisherReturnsMethods inherited from interface com.rabbitmq.client.ShutdownListenershutdownCompletedMethods inherited from interface org.springframework.context.SmartLifecycleisAutoStartup, stop
- 
Constructor Details- 
PooledChannelConnectionFactorypublic PooledChannelConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory) Construct an instance.- Parameters:
- rabbitConnectionFactory- the rabbitmq connection factory.
 
 
- 
- 
Method Details- 
setPublisherConnectionFactorypublic void setPublisherConnectionFactory(@Nullable AbstractConnectionFactory publisherConnectionFactory) Description copied from class:AbstractConnectionFactorySet a custom publisher connection factory; the type does not need to be the same as this factory.- Overrides:
- setPublisherConnectionFactoryin class- AbstractConnectionFactory
- Parameters:
- publisherConnectionFactory- the factory.
 
- 
setPoolConfigurerpublic void setPoolConfigurer(BiConsumer<org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel>, Boolean> poolConfigurer) Add a consumer to configure the object pool. The second argument is true when called with the transactional pool.- Parameters:
- poolConfigurer- the configurer.
 
- 
isSimplePublisherConfirmspublic boolean isSimplePublisherConfirms()Description copied from interface:ConnectionFactoryReturn true if simple publisher confirms are enabled.- Specified by:
- isSimplePublisherConfirmsin interface- ConnectionFactory
- Returns:
- simplePublisherConfirms
 
- 
setSimplePublisherConfirmspublic void setSimplePublisherConfirms(boolean simplePublisherConfirms) Enable simple publisher confirms.- Parameters:
- simplePublisherConfirms- true to enable.
 
- 
addConnectionListener- Specified by:
- addConnectionListenerin interface- ConnectionFactory
- Overrides:
- addConnectionListenerin class- AbstractConnectionFactory
 
- 
getPhasepublic int getPhase()- Specified by:
- getPhasein interface- Phased
- Specified by:
- getPhasein interface- SmartLifecycle
 
- 
start
- 
stop
- 
isRunning
- 
createConnection- Specified by:
- createConnectionin interface- ConnectionFactory
- Throws:
- AmqpException
 
- 
resetConnectionpublic void resetConnection()Close the connection(s). This will impact any in-process operations. New connection(s) will be created on demand after this method returns. This might be used to force a reconnect to the primary broker after failing over to a secondary broker.- Specified by:
- resetConnectionin interface- ConnectionFactory
 
- 
destroypublic void destroy()- Specified by:
- destroyin interface- DisposableBean
- Overrides:
- destroyin class- AbstractConnectionFactory
 
 
-