Package net.jodah.lyra.config
Class Config
java.lang.Object
net.jodah.lyra.config.Config
- All Implemented Interfaces:
ChannelConfig
,ConnectionConfig
,ConsumerConfig
public class Config extends java.lang.Object implements ConnectionConfig
Lyra configuration. Changes are reflected in the resources created with this configuration.
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description java.util.Collection<ChannelListener>
getChannelListeners()
Returns the channel's listeners else empty list if none were configured.RecoveryPolicy
getChannelRecoveryPolicy()
Returns the channel's recovery policy.RetryPolicy
getChannelRetryPolicy()
Returns the channel's retry policy.java.util.Collection<ConnectionListener>
getConnectionListeners()
Returns the connection's listeners else empty list if none were configured.RecoveryPolicy
getConnectionRecoveryPolicy()
Returns the connection's recovery policy.RetryPolicy
getConnectionRetryPolicy()
Returns the connection's retry policy.RetryPolicy
getConnectRetryPolicy()
Sets the policy to use for handlingconnection attempt
errors.java.util.Collection<ConsumerListener>
getConsumerListeners()
Returns the consumer listeners else empty list if none were configured.java.util.Set<java.lang.Class<? extends java.lang.Exception>>
getRecoverableExceptions()
Returns the exceptions which will be recovered from.java.util.Set<java.lang.Class<? extends java.lang.Exception>>
getRetryableExceptions()
Returns the exceptions for which invocations will be retried.boolean
isConsumerRecoveryEnabled()
Returns whether consumer recovery is enabled.boolean
isExchangeRecoveryEnabled()
Returns whether exchange and exchange binding recovery is enabled.boolean
isQueueRecoveryEnabled()
Returns whether queue and queue binding recovery is enabled.boolean
isUsingDaemonThreads()
Whether or not using daemon threads.static ConfigurableChannel
of(com.rabbitmq.client.Channel channel)
Returns thechannel
as aConfigurableChannel
.static ConfigurableConnection
of(com.rabbitmq.client.Connection connection)
Returns theconnection
as aConfigurableConnection
.Config
withChannelListeners(ChannelListener... channelListeners)
Sets thechannelListeners
to call on channel related events.Config
withChannelRecoveryPolicy(RecoveryPolicy channelRecoveryPolicy)
Sets therecoveryPolicy
to use for recovering the channel.Config
withChannelRetryPolicy(RetryPolicy channelRetryPolicy)
Sets theretryPolicy
to use for retrying failed invocations on the channel.Config
withConnectionListeners(ConnectionListener... connectionListeners)
Sets theconnectionListeners
to call on connection related events.Config
withConnectionRecoveryPolicy(RecoveryPolicy connectionRecoveryPolicy)
Sets the policy to use for the recovery of Connections after an unexpected Connection closure.Config
withConnectionRetryPolicy(RetryPolicy connectionRetryPolicy)
Sets the policy to use for handlingConnection
invocation errors.Config
withConnectRetryPolicy(RetryPolicy connectRetryPolicy)
Sets the policy to use for handling initialconnection attempt
errors.Config
withConsumerListeners(ConsumerListener... consumerListeners)
Sets theconsumerListeners
to call on consumer related events.Config
withConsumerRecovery(boolean enabled)
Sets whether consumer recovery is enabled or not.Config
withExchangeRecovery(boolean enabled)
Sets whether exchange and exchange binding recovery is enabled or not.Config
withQueueRecovery(boolean enabled)
Sets whether queue and queue binding recovery is enabled or not.Config
withRecoveryPolicy(RecoveryPolicy recoveryPolicy)
Sets the policy to use for the recovery of Connections/Channels/Consumers after an unexpected Connection/Channel closure.Config
withRetryPolicy(RetryPolicy retryPolicy)
Sets the policy to use for handlingconnection attempt
,Connection
invocation, andChannel
invocation errors.Config
withUseDaemonThreads(boolean enabled)
Whether or not using daemon threads.
-
Constructor Details
-
Method Details
-
of
Returns thechannel
as aConfigurableChannel
.- Throws:
java.lang.IllegalArgumentException
- ifchannel
was not created by Lyra
-
of
Returns theconnection
as aConfigurableConnection
.- Throws:
java.lang.IllegalArgumentException
- ifconnection
was not created by Lyra
-
getChannelListeners
Description copied from interface:ChannelConfig
Returns the channel's listeners else empty list if none were configured.- Specified by:
getChannelListeners
in interfaceChannelConfig
- See Also:
ChannelConfig.withChannelListeners(ChannelListener...)
-
getChannelRecoveryPolicy
Description copied from interface:ChannelConfig
Returns the channel's recovery policy.- Specified by:
getChannelRecoveryPolicy
in interfaceChannelConfig
- See Also:
ChannelConfig.withChannelRecoveryPolicy(RecoveryPolicy)
-
getChannelRetryPolicy
Description copied from interface:ChannelConfig
Returns the channel's retry policy.- Specified by:
getChannelRetryPolicy
in interfaceChannelConfig
- See Also:
ChannelConfig.withChannelRetryPolicy(RetryPolicy)
-
getConnectionListeners
Description copied from interface:ConnectionConfig
Returns the connection's listeners else empty list if none were configured.- Specified by:
getConnectionListeners
in interfaceConnectionConfig
- See Also:
ConnectionConfig.withConnectionListeners(ConnectionListener...)
-
getConnectionRecoveryPolicy
Description copied from interface:ConnectionConfig
Returns the connection's recovery policy.- Specified by:
getConnectionRecoveryPolicy
in interfaceConnectionConfig
- See Also:
ConnectionConfig.withConnectionRecoveryPolicy(RecoveryPolicy)
-
getConnectionRetryPolicy
Description copied from interface:ConnectionConfig
Returns the connection's retry policy.- Specified by:
getConnectionRetryPolicy
in interfaceConnectionConfig
- See Also:
ConnectionConfig.withConnectionRetryPolicy(RetryPolicy)
-
getConnectRetryPolicy
Sets the policy to use for handlingconnection attempt
errors. Overrides theglobal retry policy
. -
getConsumerListeners
Description copied from interface:ConsumerConfig
Returns the consumer listeners else empty list if none were configured.- Specified by:
getConsumerListeners
in interfaceConsumerConfig
- See Also:
ConsumerConfig.getConsumerListeners()
-
getRecoverableExceptions
public java.util.Set<java.lang.Class<? extends java.lang.Exception>> getRecoverableExceptions()Returns the exceptions which will be recovered from. By default these will includeSocketTimeoutException
,ConnectException
,AlreadyClosedException
, andTimeoutException
, but this set can be mutated directly to change the recoverable exceptions. -
getRetryableExceptions
public java.util.Set<java.lang.Class<? extends java.lang.Exception>> getRetryableExceptions()Returns the exceptions for which invocations will be retried. By default these will includeSocketTimeoutException
,ConnectException
,AlreadyClosedException
, andTimeoutException
, but this set can be mutated directly to change the retryable exceptions. -
isConsumerRecoveryEnabled
public boolean isConsumerRecoveryEnabled()Description copied from interface:ConsumerConfig
Returns whether consumer recovery is enabled. Defaults to true when channel recovery is configured.- Specified by:
isConsumerRecoveryEnabled
in interfaceConsumerConfig
- See Also:
ConsumerConfig.withConsumerRecovery(boolean)
-
isExchangeRecoveryEnabled
public boolean isExchangeRecoveryEnabled()Description copied from interface:ChannelConfig
Returns whether exchange and exchange binding recovery is enabled. Any non-durable or auto-deleting exchanges will be recovered unless they are explicitly deleted viaChannel.exchangeDelete(String)
.Defaults to true when channel recovery is configured.
- Specified by:
isExchangeRecoveryEnabled
in interfaceChannelConfig
- See Also:
ChannelConfig.withExchangeRecovery(boolean)
-
isQueueRecoveryEnabled
public boolean isQueueRecoveryEnabled()Description copied from interface:ChannelConfig
Returns whether queue and queue binding recovery is enabled. Any non-durable or auto-deleting queues will be recovered unless they are explicitly deleted viaChannel.queueDelete(String)
.Defaults to true when channel recovery is configured.
- Specified by:
isQueueRecoveryEnabled
in interfaceChannelConfig
- See Also:
ChannelConfig.withQueueRecovery(boolean)
-
isUsingDaemonThreads
public boolean isUsingDaemonThreads()Description copied from interface:ConnectionConfig
Whether or not using daemon threads.- Specified by:
isUsingDaemonThreads
in interfaceConnectionConfig
-
withChannelListeners
Description copied from interface:ChannelConfig
Sets thechannelListeners
to call on channel related events.- Specified by:
withChannelListeners
in interfaceChannelConfig
-
withChannelRecoveryPolicy
Description copied from interface:ChannelConfig
Sets therecoveryPolicy
to use for recovering the channel.- Specified by:
withChannelRecoveryPolicy
in interfaceChannelConfig
-
withChannelRetryPolicy
Description copied from interface:ChannelConfig
Sets theretryPolicy
to use for retrying failed invocations on the channel.- Specified by:
withChannelRetryPolicy
in interfaceChannelConfig
-
withConnectionListeners
Description copied from interface:ConnectionConfig
Sets theconnectionListeners
to call on connection related events.- Specified by:
withConnectionListeners
in interfaceConnectionConfig
-
withConnectionRecoveryPolicy
Description copied from interface:ConnectionConfig
Sets the policy to use for the recovery of Connections after an unexpected Connection closure.- Specified by:
withConnectionRecoveryPolicy
in interfaceConnectionConfig
-
withConnectionRetryPolicy
Description copied from interface:ConnectionConfig
Sets the policy to use for handlingConnection
invocation errors.- Specified by:
withConnectionRetryPolicy
in interfaceConnectionConfig
-
withConnectRetryPolicy
Sets the policy to use for handling initialconnection attempt
errors. Overrides theglobal retry policy
. -
withConsumerListeners
Description copied from interface:ConsumerConfig
Sets theconsumerListeners
to call on consumer related events.- Specified by:
withConsumerListeners
in interfaceConsumerConfig
-
withConsumerRecovery
Description copied from interface:ConsumerConfig
Sets whether consumer recovery is enabled or not.- Specified by:
withConsumerRecovery
in interfaceConsumerConfig
-
withExchangeRecovery
Description copied from interface:ChannelConfig
Sets whether exchange and exchange binding recovery is enabled or not. Any non-durable or auto-deleting exchanges will be recovered unless they are explicitly deleted viaChannel.exchangeDelete(String)
.- Specified by:
withExchangeRecovery
in interfaceChannelConfig
-
withQueueRecovery
Description copied from interface:ChannelConfig
Sets whether queue and queue binding recovery is enabled or not. Any non-durable or auto-deleting queues will be recovered unless they are explicitly deleted viaChannel.queueDelete(String)
.- Specified by:
withQueueRecovery
in interfaceChannelConfig
-
withUseDaemonThreads
Description copied from interface:ConnectionConfig
Whether or not using daemon threads. Default is false.- Specified by:
withUseDaemonThreads
in interfaceConnectionConfig
-
withRecoveryPolicy
Sets the policy to use for the recovery of Connections/Channels/Consumers after an unexpected Connection/Channel closure. Can be overridden with specific policies viawithConnectionRecoveryPolicy(RecoveryPolicy)
andwithChannelRecoveryPolicy(RecoveryPolicy)
. -
withRetryPolicy
Sets the policy to use for handlingconnection attempt
,Connection
invocation, andChannel
invocation errors. Can be overridden with specific policies viawithConnectRetryPolicy(RetryPolicy)
,withConnectionRetryPolicy(RetryPolicy)
, andwithChannelRetryPolicy(RetryPolicy)
.
-