public class AutorecoveringConnection extends Object implements RecoverableConnection, NetworkConnection
Modifier and Type | Field and Description |
---|---|
static Predicate<ShutdownSignalException> |
DEFAULT_CONNECTION_RECOVERY_TRIGGERING_CONDITION |
Constructor and Description |
---|
AutorecoveringConnection(ConnectionParams params,
FrameHandlerFactory f,
AddressResolver addressResolver) |
AutorecoveringConnection(ConnectionParams params,
FrameHandlerFactory f,
AddressResolver addressResolver,
MetricsCollector metricsCollector) |
AutorecoveringConnection(ConnectionParams params,
FrameHandlerFactory f,
List<Address> addrs) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort this connection and all its channels
with the
AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int timeout)
Abort this connection and all its channels
with the
AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
abort(int closeCode,
String closeMessage)
Abort this connection and all its channels.
|
void |
abort(int closeCode,
String closeMessage,
int timeout)
Abort this connection and all its channels.
|
BlockedListener |
addBlockedListener(BlockedCallback blockedCallback,
UnblockedCallback unblockedCallback)
Add a lambda-based
BlockedListener . |
void |
addBlockedListener(BlockedListener listener)
Add a
BlockedListener . |
void |
addConsumerRecoveryListener(ConsumerRecoveryListener listener)
Not part of the public API.
|
void |
addQueueRecoveryListener(QueueRecoveryListener listener)
Not part of the public API.
|
void |
addRecoveryListener(RecoveryListener listener)
Adds the recovery listener
|
void |
addShutdownListener(ShutdownListener listener)
Add shutdown listener.
|
void |
clearBlockedListeners()
Remove all
BlockedListener s. |
void |
close()
Close this connection and all its channels
with the
AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int timeout)
Close this connection and all its channels
with the
AMQP.REPLY_SUCCESS close code
and message 'OK'. |
void |
close(int closeCode,
String closeMessage)
Close this connection and all its channels.
|
void |
close(int closeCode,
String closeMessage,
int timeout)
Close this connection and all its channels.
|
Channel |
createChannel()
Create a new channel, using an internally allocated channel number.
|
Channel |
createChannel(int channelNumber)
Create a new channel, using the specified channel number if possible.
|
void |
excludeQueueFromRecovery(String queue,
boolean ifUnused)
Exclude the queue from the list of queues to recover after connection failure.
|
InetAddress |
getAddress()
Retrieve the host.
|
int |
getChannelMax()
Get the negotiated maximum channel number.
|
Map<String,Object> |
getClientProperties()
Get a copy of the map of client properties sent to the server
|
String |
getClientProvidedName()
Returns client-provided connection name, if any.
|
ShutdownSignalException |
getCloseReason()
Get the shutdown reason object
|
AMQConnection |
getDelegate()
Not supposed to be used outside of automated tests.
|
ExceptionHandler |
getExceptionHandler()
Get the exception handler.
|
int |
getFrameMax()
Get the negotiated maximum frame size.
|
int |
getHeartbeat()
Get the negotiated heartbeat interval.
|
String |
getId()
Public API - Returns a unique ID for this connection.
|
InetAddress |
getLocalAddress()
Retrieve the local host.
|
int |
getLocalPort()
Retrieve the local port number.
|
int |
getPort()
Retrieve the port number.
|
List<RecordedBinding> |
getRecordedBindings() |
Map<String,RecordedConsumer> |
getRecordedConsumers() |
Map<String,RecordedExchange> |
getRecordedExchanges() |
Map<String,RecordedQueue> |
getRecordedQueues() |
Map<String,Object> |
getServerProperties()
Retrieve the server properties.
|
void |
init()
Private API.
|
boolean |
isOpen()
Determine whether the component is currently open.
|
void |
notifyListeners()
Protected API - notify the listeners attached to the component
|
void |
recoverBinding(RecordedBinding b,
boolean retry) |
void |
recoverChannel(AutorecoveringChannel channel) |
void |
recoverChannelAndTopology(AutorecoveringChannel channel)
Recover a closed channel and all topology (i.e.
|
void |
recoverConsumer(String tag,
RecordedConsumer consumer,
boolean retry)
Recover the consumer.
|
void |
recoverExchange(RecordedExchange x,
boolean retry) |
void |
recoverQueue(String oldName,
RecordedQueue q,
boolean retry)
Recover the queue.
|
boolean |
removeBlockedListener(BlockedListener listener)
Remove a
BlockedListener . |
void |
removeConsumerRecoveryListener(ConsumerRecoveryListener listener) |
void |
removeQueueRecoveryListener(QueueRecoveryListener listener) |
void |
removeRecoveryListener(RecoveryListener listener)
Removes the recovery listener
|
void |
removeShutdownListener(ShutdownListener listener)
Remove shutdown listener for the component.
|
void |
setId(String id)
Public API - Sets a unique ID for this connection.
|
protected boolean |
shouldTriggerConnectionRecovery(ShutdownSignalException cause) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
openChannel, openChannel
public static final Predicate<ShutdownSignalException> DEFAULT_CONNECTION_RECOVERY_TRIGGERING_CONDITION
public AutorecoveringConnection(ConnectionParams params, FrameHandlerFactory f, List<Address> addrs)
public AutorecoveringConnection(ConnectionParams params, FrameHandlerFactory f, AddressResolver addressResolver)
public AutorecoveringConnection(ConnectionParams params, FrameHandlerFactory f, AddressResolver addressResolver, MetricsCollector metricsCollector)
public void init() throws IOException, TimeoutException
public Channel createChannel() throws IOException
Connection
Recoverable
.
Use Connection.openChannel()
if you want to use an Optional
to deal
with a value.
createChannel
in interface Connection
IOException
- if an I/O problem is encounteredConnection.createChannel()
public Channel createChannel(int channelNumber) throws IOException
Connection
Use Connection.openChannel(int)
if you want to use an Optional
to deal
with a value.
createChannel
in interface Connection
channelNumber
- the channel number to allocateIOException
- if an I/O problem is encounteredConnection.createChannel(int)
public Map<String,Object> getServerProperties()
Connection
getServerProperties
in interface Connection
Connection.getServerProperties()
public Map<String,Object> getClientProperties()
Connection
getClientProperties
in interface Connection
Connection.getClientProperties()
public String getClientProvidedName()
Connection
getClientProvidedName
in interface Connection
Connection.getClientProvidedName()
,
ConnectionFactory.newConnection(Address[], String)
,
ConnectionFactory.newConnection(ExecutorService, Address[], String)
public int getFrameMax()
Connection
getFrameMax
in interface Connection
Connection.getFrameMax()
public int getHeartbeat()
Connection
getHeartbeat
in interface Connection
Connection.getHeartbeat()
public int getChannelMax()
Connection
getChannelMax
in interface Connection
Connection.getChannelMax()
public boolean isOpen()
ShutdownNotifier
isOpen
in interface ShutdownNotifier
ShutdownNotifier.isOpen()
public void close() throws IOException
Connection
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
Waits for all the close operations to complete.close
in interface Connection
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if an I/O problem is encounteredConnection.close()
public void close(int timeout) throws IOException
Connection
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
This method behaves in a similar way as Connection.close()
, with the only difference
that it waits with a provided timeout for all the close operations to
complete. When timeout is reached the socket is forced to close.close
in interface Connection
timeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinityIOException
- if an I/O problem is encounteredConnection.close(int)
public void close(int closeCode, String closeMessage, int timeout) throws IOException
Connection
close
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectiontimeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinityIOException
- if an I/O problem is encounteredConnection.close(int, String, int)
public void abort()
Connection
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
Forces the connection to close.
Any encountered exceptions in the close operations are silently discarded.abort
in interface Connection
Connection.abort()
public void abort(int closeCode, String closeMessage, int timeout)
Connection
abort
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectiontimeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinityConnection.abort(int, String, int)
public void abort(int closeCode, String closeMessage)
Connection
abort
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectionConnection.abort(int, String)
public void abort(int timeout)
Connection
AMQP.REPLY_SUCCESS
close code
and message 'OK'.
This method behaves in a similar way as Connection.abort()
, with the only difference
that it waits with a provided timeout for all the close operations to
complete. When timeout is reached the socket is forced to close.abort
in interface Connection
timeout
- timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinityConnection.abort(int)
public AMQConnection getDelegate()
public ShutdownSignalException getCloseReason()
ShutdownNotifier
getCloseReason
in interface ShutdownNotifier
ShutdownNotifier.getCloseReason()
public void addBlockedListener(BlockedListener listener)
Connection
BlockedListener
.addBlockedListener
in interface Connection
listener
- the listener to addShutdownNotifier.addShutdownListener(com.rabbitmq.client.ShutdownListener)
public BlockedListener addBlockedListener(BlockedCallback blockedCallback, UnblockedCallback unblockedCallback)
Connection
BlockedListener
.addBlockedListener
in interface Connection
blockedCallback
- the callback when the connection is blockedunblockedCallback
- the callback when the connection is unblockedBlockedListener
,
BlockedCallback
,
UnblockedCallback
public boolean removeBlockedListener(BlockedListener listener)
Connection
BlockedListener
.removeBlockedListener
in interface Connection
listener
- the listener to removetrue
if the listener was found and removed,
false
otherwiseConnection.removeBlockedListener(com.rabbitmq.client.BlockedListener)
public void clearBlockedListeners()
Connection
BlockedListener
s.clearBlockedListeners
in interface Connection
Connection.clearBlockedListeners()
public void close(int closeCode, String closeMessage) throws IOException
Connection
close
in interface Connection
closeCode
- the close code (See under "Reply Codes" in the AMQP specification)closeMessage
- a message indicating the reason for closing the connectionIOException
- if an I/O problem is encounteredConnection.close(int, String)
public void addShutdownListener(ShutdownListener listener)
ShutdownNotifier
addShutdownListener
in interface ShutdownNotifier
listener
- ShutdownListener
to the componentShutdownNotifier.addShutdownListener(com.rabbitmq.client.ShutdownListener)
public void removeShutdownListener(ShutdownListener listener)
ShutdownNotifier
removeShutdownListener
in interface ShutdownNotifier
listener
- ShutdownListener
to be removedShutdownNotifier.removeShutdownListener(com.rabbitmq.client.ShutdownListener)
public void notifyListeners()
ShutdownNotifier
notifyListeners
in interface ShutdownNotifier
ShutdownNotifier.notifyListeners()
public void addRecoveryListener(RecoveryListener listener)
addRecoveryListener
in interface Recoverable
listener
- RecoveryListener
to execute after this connection recovers from network failurepublic void removeRecoveryListener(RecoveryListener listener)
removeRecoveryListener
in interface Recoverable
listener
- RecoveryListener
to removepublic ExceptionHandler getExceptionHandler()
Connection
getExceptionHandler
in interface Connection
AMQConnection.getExceptionHandler()
public int getPort()
Connection
getPort
in interface Connection
getPort
in interface NetworkConnection
Connection.getPort()
public InetAddress getAddress()
Connection
getAddress
in interface Connection
getAddress
in interface NetworkConnection
Connection.getAddress()
public InetAddress getLocalAddress()
NetworkConnection
getLocalAddress
in interface NetworkConnection
public int getLocalPort()
NetworkConnection
getLocalPort
in interface NetworkConnection
protected boolean shouldTriggerConnectionRecovery(ShutdownSignalException cause)
public void addQueueRecoveryListener(QueueRecoveryListener listener)
listener
- listener that observes queue name changes after recoverypublic void removeQueueRecoveryListener(QueueRecoveryListener listener)
listener
- listener to be removedaddQueueRecoveryListener(com.rabbitmq.client.impl.recovery.QueueRecoveryListener)
public void addConsumerRecoveryListener(ConsumerRecoveryListener listener)
listener
- listener that observes consumer tag changes after recoverypublic void removeConsumerRecoveryListener(ConsumerRecoveryListener listener)
listener
- listener to be removedaddConsumerRecoveryListener(ConsumerRecoveryListener)
public void recoverChannel(AutorecoveringChannel channel) throws IOException
IOException
public void recoverChannelAndTopology(AutorecoveringChannel channel)
getExceptionHandler()
.channel
- channel to recoverIllegalArgumentException
- if this channel is not owned by this connectionpublic void recoverExchange(RecordedExchange x, boolean retry)
public void recoverQueue(String oldName, RecordedQueue q, boolean retry)
ExceptionHandler
.oldName
- queue nameq
- recorded queueretry
- whether to retry the recovery if an error occurs and a RetryHandler was configured on the connectionpublic void recoverBinding(RecordedBinding b, boolean retry)
public void recoverConsumer(String tag, RecordedConsumer consumer, boolean retry)
ExceptionHandler
.tag
- consumer tagconsumer
- recorded consumerretry
- whether to retry the recovery if an error occurs and a RetryHandler was configured on the connectionpublic void excludeQueueFromRecovery(String queue, boolean ifUnused)
queue
- queue name to exclude from recorded recovery queuesifUnused
- if true, the RecordedQueue will only be excluded if no local consumers are using it.public Map<String,RecordedQueue> getRecordedQueues()
public Map<String,RecordedExchange> getRecordedExchanges()
public List<RecordedBinding> getRecordedBindings()
public Map<String,RecordedConsumer> getRecordedConsumers()
public String getId()
getId
in interface Connection
public void setId(String id)
setId
in interface Connection
Copyright © 2022 VMware, Inc. or its affiliates.. All rights reserved.