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
BlockedListeners. |
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, waitopenChannel, openChannelpublic 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
ConnectionRecoverable.
Use Connection.openChannel() if you want to use an Optional to deal
with a value.
createChannel in interface ConnectionIOException - 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 ConnectionchannelNumber - the channel number to allocateIOException - if an I/O problem is encounteredConnection.createChannel(int)public Map<String,Object> getServerProperties()
ConnectiongetServerProperties in interface ConnectionConnection.getServerProperties()public Map<String,Object> getClientProperties()
ConnectiongetClientProperties in interface ConnectionConnection.getClientProperties()public String getClientProvidedName()
ConnectiongetClientProvidedName in interface ConnectionConnection.getClientProvidedName(),
ConnectionFactory.newConnection(Address[], String),
ConnectionFactory.newConnection(ExecutorService, Address[], String)public int getFrameMax()
ConnectiongetFrameMax in interface ConnectionConnection.getFrameMax()public int getHeartbeat()
ConnectiongetHeartbeat in interface ConnectionConnection.getHeartbeat()public int getChannelMax()
ConnectiongetChannelMax in interface ConnectionConnection.getChannelMax()public boolean isOpen()
ShutdownNotifierisOpen in interface ShutdownNotifierShutdownNotifier.isOpen()public void close()
throws IOException
ConnectionAMQP.REPLY_SUCCESS close code
and message 'OK'.
Waits for all the close operations to complete.close in interface Connectionclose in interface Closeableclose in interface AutoCloseableIOException - if an I/O problem is encounteredConnection.close()public void close(int timeout)
throws IOException
ConnectionAMQP.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 Connectiontimeout - 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
Connectionclose in interface ConnectioncloseCode - 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()
ConnectionAMQP.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 ConnectionConnection.abort()public void abort(int closeCode,
String closeMessage,
int timeout)
Connectionabort in interface ConnectioncloseCode - 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)
Connectionabort in interface ConnectioncloseCode - 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)
ConnectionAMQP.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 Connectiontimeout - timeout (in milliseconds) for completing all the close-related
operations, use -1 for infinityConnection.abort(int)public AMQConnection getDelegate()
public ShutdownSignalException getCloseReason()
ShutdownNotifiergetCloseReason in interface ShutdownNotifierShutdownNotifier.getCloseReason()public void addBlockedListener(BlockedListener listener)
ConnectionBlockedListener.addBlockedListener in interface Connectionlistener - the listener to addShutdownNotifier.addShutdownListener(com.rabbitmq.client.ShutdownListener)public BlockedListener addBlockedListener(BlockedCallback blockedCallback, UnblockedCallback unblockedCallback)
ConnectionBlockedListener.addBlockedListener in interface ConnectionblockedCallback - the callback when the connection is blockedunblockedCallback - the callback when the connection is unblockedBlockedListener,
BlockedCallback,
UnblockedCallbackpublic boolean removeBlockedListener(BlockedListener listener)
ConnectionBlockedListener.removeBlockedListener in interface Connectionlistener - the listener to removetrue if the listener was found and removed,
false otherwiseConnection.removeBlockedListener(com.rabbitmq.client.BlockedListener)public void clearBlockedListeners()
ConnectionBlockedListeners.clearBlockedListeners in interface ConnectionConnection.clearBlockedListeners()public void close(int closeCode,
String closeMessage)
throws IOException
Connectionclose in interface ConnectioncloseCode - 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)
ShutdownNotifieraddShutdownListener in interface ShutdownNotifierlistener - ShutdownListener to the componentShutdownNotifier.addShutdownListener(com.rabbitmq.client.ShutdownListener)public void removeShutdownListener(ShutdownListener listener)
ShutdownNotifierremoveShutdownListener in interface ShutdownNotifierlistener - ShutdownListener to be removedShutdownNotifier.removeShutdownListener(com.rabbitmq.client.ShutdownListener)public void notifyListeners()
ShutdownNotifiernotifyListeners in interface ShutdownNotifierShutdownNotifier.notifyListeners()public void addRecoveryListener(RecoveryListener listener)
addRecoveryListener in interface Recoverablelistener - RecoveryListener to execute after this connection recovers from network failurepublic void removeRecoveryListener(RecoveryListener listener)
removeRecoveryListener in interface Recoverablelistener - RecoveryListener to removepublic ExceptionHandler getExceptionHandler()
ConnectiongetExceptionHandler in interface ConnectionAMQConnection.getExceptionHandler()public int getPort()
ConnectiongetPort in interface ConnectiongetPort in interface NetworkConnectionConnection.getPort()public InetAddress getAddress()
ConnectiongetAddress in interface ConnectiongetAddress in interface NetworkConnectionConnection.getAddress()public InetAddress getLocalAddress()
NetworkConnectiongetLocalAddress in interface NetworkConnectionpublic int getLocalPort()
NetworkConnectiongetLocalPort in interface NetworkConnectionprotected 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
IOExceptionpublic 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 Connectionpublic void setId(String id)
setId in interface ConnectionCopyright © 2021 VMware, Inc. or its affiliates.. All rights reserved.