Class PooledChannelConnectionFactory

  • All Implemented Interfaces:
    com.rabbitmq.client.ShutdownListener, java.util.EventListener, ConnectionFactory, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextClosedEvent>

    public class PooledChannelConnectionFactory
    extends AbstractConnectionFactory
    implements com.rabbitmq.client.ShutdownListener
    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
    • Constructor Detail

      • PooledChannelConnectionFactory

        public PooledChannelConnectionFactory​(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
        Construct an instance.
        Parameters:
        rabbitConnectionFactory - the rabbitmq connection factory.
    • Method Detail

      • setPoolConfigurer

        public void setPoolConfigurer​(java.util.function.BiConsumer<org.apache.commons.pool2.impl.GenericObjectPool<com.rabbitmq.client.Channel>,​java.lang.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.
      • setSimplePublisherConfirms

        public void setSimplePublisherConfirms​(boolean simplePublisherConfirms)
        Enable simple publisher confirms.
        Parameters:
        simplePublisherConfirms - true to enable.
      • resetConnection

        public 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:
        resetConnection in interface ConnectionFactory
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
        Overrides:
        destroy in class AbstractConnectionFactory