public class ChannelPool extends Object implements ChannelProvider
ChannelProvider strategy for non-transactional channels.
Features:
- Maintains separate pools based on ChannelPoolKey.
- Cleans up idle or closed channels periodically.
- Integrates with Mule's Scheduler for resource management.
Example usage:
// For non-transactional channels, use ChannelPool directly:
ChannelPool pool = ChannelPool.getInstance(connection, schedulerService);
MuleAmqpChannel channel = pool.getChannel(channelManager, NOT_SUPPORTED, qualityOfService, true);
pool.releaseChannel(channelManager, NOT_SUPPORTED, qualityOfService, true, channel);
// For transactional or mixed usage, use ChannelProviderFactory to get the provider:
ChannelProvider provider = ChannelProviderFactory.getProvider(connection, schedulerService, transactionalAction);
MuleAmqpChannel channel = provider.getChannel(connection, schedulerService, channelManager,
transactionalAction, qualityOfService, true);
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CHANNEL |
| Modifier and Type | Method and Description |
|---|---|
MuleAmqpChannel |
getChannel(AmqpTransactionalConnection connection,
AmqpChannelManager channelManager,
org.mule.runtime.extension.api.tx.OperationTransactionalAction transactionalAction,
QualityOfService qualityOfService,
boolean singleMessageChannel)
Retrieves an available channel from the pool or creates a new one if necessary.
|
static ChannelPool |
getInstance(AmqpTransactionalConnection connection,
org.mule.runtime.api.scheduler.SchedulerService schedulerService)
Retrieves or creates a singleton instance of
ChannelPool for the specified connection. |
void |
releaseChannel(AmqpChannelManager channelManager,
org.mule.runtime.extension.api.tx.OperationTransactionalAction transactionalAction,
QualityOfService qualityOfService,
boolean singleMessageChannel,
MuleAmqpChannel channel)
Releases a channel back to the pool for reuse or closes it if no longer valid.
|
public static final int DEFAULT_MAX_CHANNEL
public static ChannelPool getInstance(AmqpTransactionalConnection connection, org.mule.runtime.api.scheduler.SchedulerService schedulerService)
ChannelPool for the specified connection.connection - The AMQP connection for which the pool is managed.schedulerService - Mule's scheduler service for managing periodic tasks.ChannelPool.IOException - If an error occurs during initialization.public MuleAmqpChannel getChannel(AmqpTransactionalConnection connection, AmqpChannelManager channelManager, org.mule.runtime.extension.api.tx.OperationTransactionalAction transactionalAction, QualityOfService qualityOfService, boolean singleMessageChannel) throws IOException
getChannel in interface ChannelProviderconnection - The AMQP connection (unused, uses instance connection).channelManager - The channel manager responsible for managing channel lifecycles.transactionalAction - The transactional action associated with the operation.qualityOfService - Quality of Service (QoS) settings for the channel.singleMessageChannel - Whether the channel is intended for single-message operations.MuleAmqpChannel ready for use.IOException - If the maximum number of channels is reached or channel creation fails.public void releaseChannel(AmqpChannelManager channelManager, org.mule.runtime.extension.api.tx.OperationTransactionalAction transactionalAction, QualityOfService qualityOfService, boolean singleMessageChannel, MuleAmqpChannel channel)
channel - The MuleAmqpChannel to be released.
If the channel is invalid (e.g., closed), it will be discarded.Copyright © 2025 MuleSoft, Inc.. All rights reserved.