E
- the Type of the Provider instance being wrapped.public class ProviderWrapper<E extends Provider> extends Object implements Provider, ProviderListener
Provider
instance to wrap around another and provide some additional
features beyond the normal Provider
interface.
This wrapper is meant primarily for Providers that are adding some additional feature
on-top of an existing provider such as a discovery based provider that only needs to
pass along discovered remote peer information.Modifier and Type | Field and Description |
---|---|
protected ProviderListener |
listener |
protected E |
next |
Constructor and Description |
---|
ProviderWrapper(E next) |
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 |
close()
Closes this Provider terminating all connections and canceling any pending
operations.
|
void |
commit(JmsTransactionInfo transactionInfo,
AsyncResult request)
Called to commit an open transaction.
|
void |
connect()
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.
|
JmsMessageFactory |
getMessageFactory()
Gets the Provider specific Message factory for use in the JMS layer when a Session
is asked to create a Message type.
|
Provider |
getNext() |
ProviderListener |
getProviderListener()
Gets the currently set ProdiverListener instance.
|
URI |
getRemoteURI()
Returns the URI used to configure this Provider and specify the remote address of the
Broker it connects to.
|
void |
onConnectionEstablished(URI remoteURI)
Called to indicate that the underlying connection to the Broker has been established
for the first time.
|
void |
onConnectionFailure(IOException ex)
Called to indicate that the underlying connection to the Broker has been lost and
the Provider will not perform any reconnect.
|
void |
onConnectionInterrupted(URI remoteURI)
Called from a fault tolerant Provider instance to signal that the underlying
connection to the Broker has been lost.
|
void |
onConnectionRecovered(Provider provider)
Called to indicate that a connection to the Broker has been reestablished and
that all recovery operations have succeeded and the connection will now be
transitioned to a recovered state.
|
void |
onConnectionRecovery(Provider provider)
Called to indicate that a connection to the Broker has been reestablished and
that notified listener should start to recover it's state.
|
void |
onConnectionRestored(URI remoteURI)
Called to signal that all recovery operations are now complete and the Provider
is again in a normal connected state.
|
void |
onInboundMessage(JmsInboundMessageDispatch envelope)
Called when a new Message has arrived for a registered consumer.
|
void |
onProviderException(Exception cause)
Called to indicate that a some client operation caused or received an
error that is not considered fatal at the provider level.
|
void |
onResourceRemotelyClosed(JmsResource resource,
Exception cause)
Called to indicate that a currently active resource has been closed on the
remote end due to management or 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 |
rollback(JmsTransactionInfo transactionInfo,
AsyncResult request)
Called to roll back an open transaction.
|
void |
send(JmsOutboundMessageDispatch envelope,
AsyncResult request)
Sends the JmsMessage contained in the outbound dispatch envelope.
|
void |
setProviderListener(ProviderListener listener)
Sets the listener of events from this Provider instance.
|
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. |
void |
unsubscribe(String subscription,
AsyncResult request)
Remove a durable topic subscription by name.
|
protected ProviderListener listener
public ProviderWrapper(E next)
public void connect() throws IOException
Provider
connect
in interface Provider
IOException
- if the remote resource can not be contacted.public void start() throws IOException, IllegalStateException
Provider
start
in interface Provider
IOException
- if an error occurs during start processing.IllegalStateException
- if the Provider is improperly configured.public void close()
Provider
public URI getRemoteURI()
Provider
getRemoteURI
in interface Provider
public void create(JmsResource resource, AsyncResult request) throws IOException, javax.jms.JMSException, UnsupportedOperationException
Provider
create
in interface Provider
resource
- The JmsResouce instance that indicates what is being created.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as bad credentials.UnsupportedOperationException
public void start(JmsResource resource, AsyncResult request) throws IOException, javax.jms.JMSException
Provider
start
in interface Provider
resource
- The JmsResouce instance that indicates what is being started.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as already closed resource.public void stop(JmsResource resource, AsyncResult request) throws IOException, javax.jms.JMSException
Provider
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.
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 IOException 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 Provider
resource
- The JmsResouce instance that indicates what is being stopped.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as already closed resource.public void destroy(JmsResource resourceId, AsyncResult request) throws IOException, javax.jms.JMSException, UnsupportedOperationException
Provider
destroy
in interface Provider
resourceId
- The JmsResouce that identifies a previously created JmsResource.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as not authorized.UnsupportedOperationException
public void send(JmsOutboundMessageDispatch envelope, AsyncResult request) throws IOException, javax.jms.JMSException
Provider
send
in interface Provider
envelope
- the message envelope containing the JmsMessage to send.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error that maps to JMS occurs such as not authorized.public void acknowledge(JmsSessionId sessionId, ProviderConstants.ACK_TYPE ackType, AsyncResult request) throws IOException, javax.jms.JMSException
Provider
acknowledge
in interface Provider
sessionId
- 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.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as unmatched ack.public void acknowledge(JmsInboundMessageDispatch envelope, ProviderConstants.ACK_TYPE ackType, AsyncResult request) throws IOException, javax.jms.JMSException
Provider
acknowledge
in interface Provider
envelope
- 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.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such as unmatched ack.public void commit(JmsTransactionInfo transactionInfo, AsyncResult request) throws IOException, javax.jms.JMSException, UnsupportedOperationException
Provider
commit
in interface Provider
transactionInfo
- the transaction info that describes the transaction being committed.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such not authorized.UnsupportedOperationException
public void rollback(JmsTransactionInfo transactionInfo, AsyncResult request) throws IOException, javax.jms.JMSException, UnsupportedOperationException
Provider
rollback
in interface Provider
transactionInfo
- the transaction info that describes the transaction being rolled back.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such not authorized.UnsupportedOperationException
public void recover(JmsSessionId sessionId, AsyncResult request) throws IOException, UnsupportedOperationException
Provider
recover
in interface Provider
sessionId
- the Id of the JmsSession that is recovering unacknowledged messages..request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.UnsupportedOperationException
public void unsubscribe(String subscription, AsyncResult request) throws IOException, javax.jms.JMSException, UnsupportedOperationException
Provider
unsubscribe
in interface Provider
subscription
- the name of the durable subscription that is to be removed.request
- The request object that should be signaled when this operation completes.IOException
- if an error occurs or the Provider is already closed.javax.jms.JMSException
- if an error occurs due to JMS violation such not authorized.UnsupportedOperationException
public void pull(JmsConsumerId consumerId, long timeout, AsyncResult request) throws IOException, UnsupportedOperationException
Provider
pull
in interface Provider
consumerId
- 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.IOException
- if an error occurs or the Provider is already closed.UnsupportedOperationException
public JmsMessageFactory getMessageFactory()
Provider
getMessageFactory
in interface Provider
public void setProviderListener(ProviderListener listener)
Provider
setProviderListener
in interface Provider
listener
- The listener instance that will receive all event callbacks.public ProviderListener getProviderListener()
Provider
getProviderListener
in interface Provider
public void onInboundMessage(JmsInboundMessageDispatch envelope)
ProviderListener
onInboundMessage
in interface ProviderListener
envelope
- The dispatch object containing the message and delivery information.public void onConnectionInterrupted(URI remoteURI)
ProviderListener
onConnectionInterrupted
in interface ProviderListener
remoteURI
- The URI of the Broker whose connection was lost.public void onConnectionRecovery(Provider provider) throws Exception
ProviderListener
onConnectionRecovery
in interface ProviderListener
provider
- The new Provider instance that will become active after the state
has been recovered.Exception
- if an error occurs during recovery attempt, this will fail
the Provider that's being used for recovery.public void onConnectionRecovered(Provider provider) throws Exception
ProviderListener
onConnectionRecovered
in interface ProviderListener
provider
- The new Provider instance that will become active after the state
has been recovered.Exception
- if an error occurs during recovery attempt, this will fail
the Provider that's being used for recovery.public void onConnectionRestored(URI remoteURI)
ProviderListener
onConnectionRestored
in interface ProviderListener
remoteURI
- The URI of the Broker that the client has now connected to.public void onConnectionEstablished(URI remoteURI)
ProviderListener
onConnectionEstablished
in interface ProviderListener
remoteURI
- The URI of the Broker that the client has now connected to.public void onConnectionFailure(IOException ex)
ProviderListener
onConnectionFailure
in interface ProviderListener
ex
- The exception that indicates the cause of this Provider failure.public void onResourceRemotelyClosed(JmsResource resource, Exception cause)
ProviderListener
onResourceRemotelyClosed
in interface ProviderListener
resource
- the JmsResource instance that has been remotely closed.cause
- optional exception object that indicates the cause of the close.public void onProviderException(Exception cause)
ProviderListener
onProviderException
in interface ProviderListener
cause
- the exception object that is being reported to the listener.public Provider getNext()
Copyright © 2013–2016 The Apache Software Foundation. All rights reserved.