public class FailoverProvider extends DefaultProviderListener implements Provider
| Modifier and Type | Class and Description |
|---|---|
protected class |
FailoverProvider.CreateConnectionRequest
Captures the initial request to create a JmsConnectionInfo based resources and ensures
that if the connection is successfully established that the connection established event
is triggered once before moving on to sending only connection interrupted and restored
events.
|
protected class |
FailoverProvider.FailoverRequest
For all requests that are dispatched from the FailoverProvider to a connected
Provider instance an instance of FailoverRequest is used to handle errors that
occur during processing of that request and trigger a reconnect.
|
protected class |
FailoverProvider.FailoverRequestSweeper |
| Modifier and Type | Field and Description |
|---|---|
static long |
DEFAULT_INITIAL_RECONNECT_DELAY |
static int |
DEFAULT_MAX_RECONNECT_ATTEMPTS |
static long |
DEFAULT_MAX_RECONNECT_DELAY |
static double |
DEFAULT_RECONNECT_BACKOFF_MULTIPLIER |
static long |
DEFAULT_RECONNECT_DELAY |
static int |
DEFAULT_STARTUP_MAX_RECONNECT_ATTEMPTS |
static boolean |
DEFAULT_USE_RECONNECT_BACKOFF |
static int |
DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS |
static int |
UNLIMITED |
| Constructor and Description |
|---|
FailoverProvider(List<URI> uris,
Map<String,String> nestedOptions,
ProviderFutureFactory futureFactory) |
| Modifier and Type | Method and Description |
|---|---|
void |
acknowledge(JmsInboundMessageDispatch envelope,
ProviderConstants.ACK_TYPE ackType,
AsyncResult request)
Called to acknowledge a JmsMessage has been delivered, consumed, re-delivered...etc.
|
void |
acknowledge(JmsSessionId sessionId,
ProviderConstants.ACK_TYPE ackType,
AsyncResult request)
Called to acknowledge all messages that have been delivered in a given session.
|
void |
add(URI uri) |
protected void |
checkClosed() |
void |
close()
Closes this Provider terminating all connections and canceling any pending
operations.
|
void |
commit(JmsTransactionInfo transactionInfo,
JmsTransactionInfo nextTransactionInfo,
AsyncResult request)
Called to commit an open transaction, and start a new one if a new transaction info
object is provided.
|
void |
connect(JmsConnectionInfo connectionInfo)
Performs the initial low level connection for this provider such as TCP or
SSL connection to a remote Broker.
|
void |
create(JmsResource resource,
AsyncResult request)
Create the Provider version of the given JmsResource.
|
void |
destroy(JmsResource resourceId,
AsyncResult request)
Instruct the Provider to dispose of a given JmsResource.
|
List<URI> |
getAlternateURIs()
Returns a
List of alternate remote peers (possibly found via discovery) to
which the caller can attempt a recoonect should this provider connection fail. |
String |
getAmqpOpenServerListAction() |
long |
getCloseTimeout() |
long |
getInitialReconnectDelay() |
int |
getMaxReconnectAttempts() |
long |
getMaxReconnectDelay() |
JmsMessageFactory |
getMessageFactory()
Gets the Provider specific Message factory for use in the JMS layer when a Session
is asked to create a Message type.
|
Map<String,String> |
getNestedOptions() |
ProviderListener |
getProviderListener()
Gets the currently set ProdiverListener instance.
|
double |
getReconnectBackOffMultiplier() |
long |
getReconnectDelay() |
URI |
getRemoteURI()
Returns the URI used to configure this Provider and specify the remote address of the
Broker it connects to.
|
protected long |
getRequestSweeperInterval() |
long |
getRequestTimeout() |
long |
getSendTimeout() |
int |
getStartupMaxReconnectAttempts() |
int |
getWarnAfterReconnectAttempts()
Gets the current setting controlling how many Connect / Reconnect attempts must occur
before a warn message is logged.
|
boolean |
isRandomize() |
boolean |
isUseReconnectBackOff() |
ProviderFuture |
newProviderFuture()
Gets a ProviderFuture instance from the Provider for use in performing Provider calls
that require an asynchronous completion to know when the call to the provider has succeeded
or failed.
|
ProviderFuture |
newProviderFuture(ProviderSynchronization synchronization)
Gets a ProviderFuture instance from the Provider for use in performing Provider calls
that require an asynchronous completion to know when the call to the provider has succeeded
or failed.
|
void |
onCompletedMessageSend(JmsOutboundMessageDispatch envelope)
Called when an outbound message dispatch that requested a completion callback
has reached a state where the send can be considered successful based on the QoS
level associated of the outbound message.
|
void |
onConnectionFailure(ProviderException ex)
Called to indicate that the underlying connection to the Broker has been lost and
the Provider will not perform any reconnect.
|
void |
onFailedMessageSend(JmsOutboundMessageDispatch envelope,
ProviderException cause)
Called when an outbound message dispatch that requested a completion callback
has reached a state where the send can be considered failed.
|
void |
onInboundMessage(JmsInboundMessageDispatch envelope)
Called when a new Message has arrived for a registered consumer.
|
void |
onProviderException(ProviderException ex)
Called to indicate that a some client operation caused or received an
error that is not considered fatal at the provider level.
|
void |
onResourceClosed(JmsResource resource,
ProviderException cause)
Called to indicate that a currently active resource has been closed
due to some error condition, management request or some other action.
|
void |
pull(JmsConsumerId consumerId,
long timeout,
AsyncResult request)
Request a remote peer send a Message to this client.
|
void |
recover(JmsSessionId sessionId,
AsyncResult request)
Called to recover all unacknowledged messages for a Session in client Ack mode.
|
void |
remove(URI uri) |
void |
rollback(JmsTransactionInfo transactionInfo,
JmsTransactionInfo nextTransactionInfo,
AsyncResult request)
Called to roll back an open transaction, and start a new one if a new transaction info
object is provided.
|
void |
send(JmsOutboundMessageDispatch envelope,
AsyncResult request)
Sends the JmsMessage contained in the outbound dispatch envelope.
|
void |
setAmqpOpenServerListAction(String amqpOpenServerListAction) |
void |
setInitialReconnectDelay(long initialReconnectDelay) |
void |
setMaxReconnectAttempts(int maxReconnectAttempts) |
void |
setMaxReconnectDelay(long maxReconnectDelay) |
void |
setProviderListener(ProviderListener listener)
Sets the listener of events from this Provider instance.
|
void |
setRandomize(boolean value) |
void |
setReconnectBackOffMultiplier(double reconnectBackOffMultiplier) |
void |
setReconnectDelay(long reconnectDealy) |
void |
setStartupMaxReconnectAttempts(int startupMaxReconnectAttempts) |
void |
setUseReconnectBackOff(boolean useReconnectBackOff) |
void |
setWarnAfterReconnectAttempts(int warnAfterReconnectAttempts)
Sets the number of Connect / Reconnect attempts that must occur before a warn message
is logged indicating that the transport is not connected.
|
void |
start()
Starts the Provider.
|
void |
start(JmsResource resource,
AsyncResult request)
Starts the Provider version of the given JmsResource.
|
void |
stop(JmsResource resource,
AsyncResult request)
Stops (pauses) the Provider version of the given JmsResource, the resource would then
need to be started again via a call to
start()
For some JMS Resources it is necessary or advantageous to have a stopped state that
can be triggered to stop the resource generating new events or messages. |
String |
toString() |
void |
unsubscribe(String subscription,
AsyncResult request)
Remove a durable topic subscription by name.
|
onConnectionEstablished, onConnectionInterrupted, onConnectionRecovered, onConnectionRecovery, onConnectionRestoredpublic static final int UNLIMITED
public static final int DEFAULT_MAX_RECONNECT_ATTEMPTS
public static final int DEFAULT_STARTUP_MAX_RECONNECT_ATTEMPTS
public static final long DEFAULT_INITIAL_RECONNECT_DELAY
public static final long DEFAULT_RECONNECT_DELAY
public static final long DEFAULT_MAX_RECONNECT_DELAY
public static final boolean DEFAULT_USE_RECONNECT_BACKOFF
public static final double DEFAULT_RECONNECT_BACKOFF_MULTIPLIER
public static final int DEFAULT_WARN_AFTER_RECONNECT_ATTEMPTS
public void connect(JmsConnectionInfo connectionInfo) throws ProviderException
Providerconnect in interface ProviderconnectionInfo - The JmsConnectionInfo that contains the properties that define this connection.ProviderException - if the remote resource can not be contacted.public void start()
throws ProviderException,
IllegalStateException
Providerstart in interface ProviderProviderException - if an error occurs during start processing.IllegalStateException - if the Provider is improperly configured.public void close()
Providerpublic void create(JmsResource resource, AsyncResult request) throws ProviderException
Providercreate in interface Providerresource - The JmsResouce instance that indicates what is being created.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void start(JmsResource resource, AsyncResult request) throws ProviderException
Providerstart in interface Providerresource - The JmsResouce instance that indicates what is being started.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void stop(JmsResource resource, AsyncResult request) throws ProviderException
Providerstart()
For some JMS Resources it is necessary or advantageous to have a stopped state that
can be triggered to stop the resource generating new events or messages.
An example of this would be a JMS Session which should not receive any incoming messages
for any consumers until the JMS layer is in a state to handle them. One such time would be
during a transaction rollback. A JMS Session should normally ensure that messages received
in a transaction are set to be redelivered prior to any new deliveries on a transaction
rollback.
The provider is required to implement this method and not throw any error other than
an ProviderException if a communication error occurs. The stop operation is not required to
have any effect on the provider resource but must not throw UnsupportedOperation etc.stop in interface Providerresource - The JmsResouce instance that indicates what is being stopped.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void destroy(JmsResource resourceId, AsyncResult request) throws ProviderException
Providerdestroy in interface ProviderresourceId - The JmsResouce that identifies a previously created JmsResource.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void send(JmsOutboundMessageDispatch envelope, AsyncResult request) throws ProviderException
Providersend in interface Providerenvelope - the message envelope containing the JmsMessage to send.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void acknowledge(JmsSessionId sessionId, ProviderConstants.ACK_TYPE ackType, AsyncResult request) throws ProviderException
Provideracknowledge in interface ProvidersessionId - the ID of the Session whose delivered messages should be acknowledged.ackType - The type of acknowledgement being done.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void acknowledge(JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType, AsyncResult request) throws ProviderException
Provideracknowledge in interface Providerenvelope - The message dispatch envelope containing the Message delivery information.ackType - The type of acknowledgement being done.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void commit(JmsTransactionInfo transactionInfo, JmsTransactionInfo nextTransactionInfo, AsyncResult request) throws ProviderException
Providercommit in interface ProvidertransactionInfo - the transaction info that describes the transaction being committed.nextTransactionInfo - the transaction info that describes the new transaction that should be created.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void rollback(JmsTransactionInfo transactionInfo, JmsTransactionInfo nextTransactionInfo, AsyncResult request) throws ProviderException
Providerrollback in interface ProvidertransactionInfo - the transaction info that describes the transaction being rolled back.nextTransactionInfo - the transaction info that describes the new transaction that should be created.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void recover(JmsSessionId sessionId, AsyncResult request) throws ProviderException
Providerrecover in interface ProvidersessionId - the Id of the JmsSession that is recovering unacknowledged messages..request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void unsubscribe(String subscription, AsyncResult request) throws ProviderException
Providerunsubscribe in interface Providersubscription - the name of the durable subscription that is to be removed.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public void pull(JmsConsumerId consumerId, long timeout, AsyncResult request) throws ProviderException
Providerpull in interface ProviderconsumerId - the ID of the Consumer instance that is attempt to pull a message from the remote.timeout - the amount of time to tell the remote peer to keep this pull request valid.request - The request object that should be signaled when this operation completes.ProviderException - if an error occurs or the Provider is already closed.public JmsMessageFactory getMessageFactory()
ProvidergetMessageFactory in interface Providerprotected void checkClosed()
throws ProviderException
ProviderExceptionpublic void onInboundMessage(JmsInboundMessageDispatch envelope)
ProviderListeneronInboundMessage in interface ProviderListeneronInboundMessage in class DefaultProviderListenerenvelope - The dispatch object containing the message and delivery information.public void onCompletedMessageSend(JmsOutboundMessageDispatch envelope)
ProviderListeneronCompletedMessageSend in interface ProviderListeneronCompletedMessageSend in class DefaultProviderListenerenvelope - the original outbound message dispatch that is now complete.public void onFailedMessageSend(JmsOutboundMessageDispatch envelope, ProviderException cause)
ProviderListeneronFailedMessageSend in interface ProviderListeneronFailedMessageSend in class DefaultProviderListenerenvelope - the original outbound message dispatch that should be treated as a failed send.cause - the exception that describes the cause of the failed send.public void onConnectionFailure(ProviderException ex)
ProviderListeneronConnectionFailure in interface ProviderListeneronConnectionFailure in class DefaultProviderListenerex - The exception that indicates the cause of this Provider failure.public void onResourceClosed(JmsResource resource, ProviderException cause)
ProviderListeneronResourceClosed in interface ProviderListeneronResourceClosed in class DefaultProviderListenerresource - the JmsResource instance that has been closed.cause - optional exception object that indicates the cause of the close.public void onProviderException(ProviderException ex)
ProviderListeneronProviderException in interface ProviderListeneronProviderException in class DefaultProviderListenerex - the exception object that is being reported to the listener.public void add(URI uri)
public void remove(URI uri)
public URI getRemoteURI()
ProvidergetRemoteURI in interface Providerpublic List<URI> getAlternateURIs()
ProviderList of alternate remote peers (possibly found via discovery) to
which the caller can attempt a recoonect should this provider connection fail. If there
are no known alternates this method returns an empty List.getAlternateURIs in interface Providerpublic void setProviderListener(ProviderListener listener)
ProvidersetProviderListener in interface Providerlistener - The listener instance that will receive all event callbacks.public ProviderListener getProviderListener()
ProvidergetProviderListener in interface Providerpublic boolean isRandomize()
public void setRandomize(boolean value)
public long getInitialReconnectDelay()
public void setInitialReconnectDelay(long initialReconnectDelay)
public long getReconnectDelay()
public void setReconnectDelay(long reconnectDealy)
public long getMaxReconnectDelay()
public void setMaxReconnectDelay(long maxReconnectDelay)
public int getMaxReconnectAttempts()
public void setMaxReconnectAttempts(int maxReconnectAttempts)
public int getStartupMaxReconnectAttempts()
public void setStartupMaxReconnectAttempts(int startupMaxReconnectAttempts)
public int getWarnAfterReconnectAttempts()
public void setWarnAfterReconnectAttempts(int warnAfterReconnectAttempts)
warnAfterReconnectAttempts - The number of failed connection attempts that must happen before a warning is logged.public double getReconnectBackOffMultiplier()
public void setReconnectBackOffMultiplier(double reconnectBackOffMultiplier)
public boolean isUseReconnectBackOff()
public void setUseReconnectBackOff(boolean useReconnectBackOff)
public long getCloseTimeout()
public long getSendTimeout()
public long getRequestTimeout()
public String getAmqpOpenServerListAction()
public void setAmqpOpenServerListAction(String amqpOpenServerListAction)
public ProviderFuture newProviderFuture()
ProvidernewProviderFuture in interface Providerpublic ProviderFuture newProviderFuture(ProviderSynchronization synchronization)
ProvidernewProviderFuture in interface Providersynchronization - A ProviderSynchronization to assign to the resulting ProviderFuture.protected final long getRequestSweeperInterval()
Copyright © 2013–2019 The Apache Software Foundation. All rights reserved.