Class PooledChannel

java.lang.Object
fr.codinbox.connector.commons.rabbitmq.PooledChannel
All Implemented Interfaces:
AutoCloseable

public class PooledChannel extends Object implements AutoCloseable
A pooled RabbitMQ channel wrapper that implements AutoCloseable to automatically return the channel to the pool when closed.

This class provides both raw channel access and convenience methods for common RabbitMQ operations. It should always be used within a try-with-resources block:


 try (PooledChannel ch = connection.borrowChannel()) {
     ch.basicPublish("exchange", "routingKey", null, "hello".getBytes());
 }
 

Closing this wrapper does not close the underlying channel; it returns it to the pool for reuse.

See Also: