public class AmqpProvider extends Object implements Provider, TransportListener, AmqpResourceParent
| Constructor and Description |
|---|
AmqpProvider(URI remoteURI,
Transport transport,
ProviderFutureFactory futureFactory)
Create a new instance of an AmqpProvider bonded to the given remote URI.
|
| 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 |
addChildResource(AmqpResource resource)
Adds the given resource as a child of this resource so that it's
lifetime becomes managed by that of its parent.
|
void |
close()
Closes this Provider terminating all connections and canceling any pending
operations.
|
void |
commit(JmsTransactionInfo transactionInfo,
JmsTransactionInfo nextTransactionId,
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 resource,
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. |
int |
getAnonymousFallbackCacheSize() |
int |
getAnonymousFallbackCacheTimeout() |
int |
getChannelMax() |
long |
getCloseTimeout() |
long |
getConnectTimeout() |
int |
getDrainTimeout() |
int |
getIdleTimeout() |
int |
getMaxFrameSize() |
int |
getMaxWriteBytesBeforeFlush() |
JmsMessageFactory |
getMessageFactory()
Gets the Provider specific Message factory for use in the JMS layer when a Session
is asked to create a Message type.
|
org.apache.qpid.proton.engine.Connection |
getProtonConnection() |
org.apache.qpid.proton.engine.Transport |
getProtonTransport() |
AmqpProvider |
getProvider() |
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.
|
long |
getRequestTimeout() |
Set<String> |
getSaslMechanisms() |
long |
getSendTimeout() |
long |
getSessionOutgoingWindow() |
int |
getTraceFramesPayloadLimit() |
Transport |
getTransport() |
String |
getVhost() |
boolean |
isAllowNonSecureRedirects() |
boolean |
isSaslLayer() |
boolean |
isTraceBytes() |
boolean |
isTraceFrames() |
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 |
onData(io.netty.buffer.ByteBuf input)
Called when new incoming data has become available.
|
void |
onTransportClosed()
Callback method for the Transport to report that the underlying connection
has closed.
|
void |
onTransportError(Throwable error)
Callback method for the Transport to report connection errors.
|
void |
pull(JmsConsumerId consumerId,
long timeout,
AsyncResult request)
Request a remote peer send a Message to this client.
|
protected boolean |
pumpToProtonTransport() |
protected boolean |
pumpToProtonTransport(AsyncResult request) |
protected boolean |
pumpToProtonTransport(AsyncResult request,
boolean flush) |
void |
recover(JmsSessionId sessionId,
AsyncResult request)
Called to recover all unacknowledged messages for a Session in client Ack mode.
|
void |
removeChildResource(AmqpResource resource)
Removes the given resource from the registered child resources
managed by this one.
|
void |
rollback(JmsTransactionInfo transactionInfo,
JmsTransactionInfo nextTransactionId,
AsyncResult request)
Called to roll back an open transaction, and start a new one if a new transaction info
object is provided.
|
void |
scheduleExecuteAndPump(Runnable task) |
ScheduledFuture<?> |
scheduleRequestTimeout(AsyncResult request,
long timeout,
AmqpExceptionBuilder builder)
Allows a resource to request that its parent resource schedule a future
cancellation of a request and return it a
Future instance that
can be used to cancel the scheduled automatic failure of the request. |
ScheduledFuture<?> |
scheduleRequestTimeout(AsyncResult request,
long timeout,
ProviderException error)
Allows a resource to request that its parent resource schedule a future
cancellation of a request and return it a
Future instance that
can be used to cancel the scheduled automatic failure of the request. |
void |
send(JmsOutboundMessageDispatch envelope,
AsyncResult request)
Sends the JmsMessage contained in the outbound dispatch envelope.
|
void |
setAllowNonSecureRedirects(boolean allowNonSecureRedirects)
Should the AMQP connection allow a redirect or failover server update that redirects
from a secure connection to an non-secure one (SSL to TCP).
|
void |
setAnonymousFallbackCacheSize(int size)
Sets the number of anonymous fallback producers to keep open in a cache in order to improve
overall performance of anonymous fallback producer sends.
|
void |
setAnonymousFallbackCacheTimeout(int timeout)
Sets the timeout used to close cached anonymous producers that have not sent any messages in that
time period.
|
void |
setChannelMax(int channelMax) |
void |
setDrainTimeout(int drainTimeout)
Sets the drain timeout (in milliseconds) after which a consumer will be
treated as having failed and will be closed due to unknown state of the
remote having not responded to the requested drain.
|
void |
setIdleTimeout(int idleTimeout)
Sets the idle timeout (in milliseconds) after which the connection will
be closed if the peer has not send any data.
|
void |
setMaxFrameSize(int maxFrameSize)
Sets the max frame size (in bytes).
|
void |
setMaxWriteBytesBeforeFlush(int maxWriteBytesBeforeFlush)
Sets the maximum number of bytes that will be written on a large set of batched writes
before a flush is requested on the
Transport. |
void |
setProviderListener(ProviderListener listener)
Sets the listener of events from this Provider instance.
|
void |
setSaslLayer(boolean saslLayer)
Sets whether a sasl layer is used for the connection or not.
|
void |
setSaslMechanisms(String[] saslMechanisms)
Sets a selection of mechanisms to restrict the choice to, enabling only
a subset of the servers offered mechanisms to be selectable.
|
void |
setSessionOutgoingWindow(long sessionOutoingWindow)
Sets the outgoing window size for the AMQP session.
|
void |
setTraceBytes(boolean trace) |
void |
setTraceFrames(boolean trace) |
void |
setTraceFramesPayloadLimit(int traceFramesPayloadLimit) |
void |
setVhost(String vhost)
Sets the hostname to be used in the AMQP SASL Init and Open frames.
|
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.
|
public AmqpProvider(URI remoteURI, Transport transport, ProviderFutureFactory futureFactory)
remoteURI - The URI of the AMQP broker this Provider instance will connect to.transport - The underlying Transport that will be used for wire level communications.futureFactory - The ProviderFutureFactory to use when futures are requested.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 resource, AsyncResult request) throws ProviderException
Providerdestroy in interface Providerresource - 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 nextTransactionId, AsyncResult request) throws ProviderException
Providercommit in interface ProvidertransactionInfo - the transaction info that describes the transaction being committed.nextTransactionId - 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 nextTransactionId, AsyncResult request) throws ProviderException
Providerrollback in interface ProvidertransactionInfo - the transaction info that describes the transaction being rolled back.nextTransactionId - 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 void scheduleExecuteAndPump(Runnable task)
public void onData(io.netty.buffer.ByteBuf input)
TransportListeneronData in interface TransportListenerinput - the next incoming packet of data.public void onTransportError(Throwable error)
onTransportError in interface TransportListenererror - the error that causes the transport to fail.public void onTransportClosed()
onTransportClosed in interface TransportListenerprotected boolean pumpToProtonTransport()
protected boolean pumpToProtonTransport(AsyncResult request)
protected boolean pumpToProtonTransport(AsyncResult request, boolean flush)
public void addChildResource(AmqpResource resource)
AmqpResourceParentaddChildResource in interface AmqpResourceParentresource - The AmqpResource that is a child of this one.public void removeChildResource(AmqpResource resource)
AmqpResourceParentremoveChildResource in interface AmqpResourceParentresource - The AmqpResource that is no longer a child of this one.public JmsMessageFactory getMessageFactory()
ProvidergetMessageFactory in interface Providerpublic ProviderFuture newProviderFuture()
ProvidernewProviderFuture in interface Providerpublic ProviderFuture newProviderFuture(ProviderSynchronization synchronization)
ProvidernewProviderFuture in interface Providersynchronization - A ProviderSynchronization to assign to the resulting ProviderFuture.public void setTraceFrames(boolean trace)
public boolean isTraceFrames()
public int getTraceFramesPayloadLimit()
public void setTraceFramesPayloadLimit(int traceFramesPayloadLimit)
public void setTraceBytes(boolean trace)
public boolean isTraceBytes()
public boolean isSaslLayer()
public void setSaslLayer(boolean saslLayer)
saslLayer - true to enable the sasl layer, false to disable it.public void setSaslMechanisms(String[] saslMechanisms)
saslMechanisms - the mechanisms to restrict choice to, or null not to restrict.public String getVhost()
public void setVhost(String vhost)
vhost - the hostname to include in SASL Init and Open frames.public int getIdleTimeout()
public void setIdleTimeout(int idleTimeout)
idleTimeout - the timeout in milliseconds.public int getDrainTimeout()
public void setDrainTimeout(int drainTimeout)
drainTimeout - the drainTimeout to use for receiver links.public int getMaxFrameSize()
public int getMaxWriteBytesBeforeFlush()
public void setMaxWriteBytesBeforeFlush(int maxWriteBytesBeforeFlush)
Transport.maxWriteBytesBeforeFlush - number of bytes written before a flush is requested.public int getAnonymousFallbackCacheSize()
public void setAnonymousFallbackCacheSize(int size)
size - The number of fallback producers to cache.public int getAnonymousFallbackCacheTimeout()
public void setAnonymousFallbackCacheTimeout(int timeout)
timeout - Time in milliseconds that a cache anonymous producer can be idle before being close.public void setMaxFrameSize(int maxFrameSize)
maxFrameSize - the frame size in bytes.public long getSessionOutgoingWindow()
public void setSessionOutgoingWindow(long sessionOutoingWindow)
sessionOutoingWindow - the outgoing window sizepublic boolean isAllowNonSecureRedirects()
public void setAllowNonSecureRedirects(boolean allowNonSecureRedirects)
allowNonSecureRedirects - the allowNonSecureRedirects value to apply to this AMQP connection.public long getCloseTimeout()
public long getConnectTimeout()
public long getRequestTimeout()
public long getSendTimeout()
public int getChannelMax()
public void setChannelMax(int channelMax)
public Transport getTransport()
public void setProviderListener(ProviderListener listener)
ProvidersetProviderListener in interface Providerlistener - The listener instance that will receive all event callbacks.public ProviderListener getProviderListener()
ProvidergetProviderListener in interface Providerpublic 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 org.apache.qpid.proton.engine.Transport getProtonTransport()
public org.apache.qpid.proton.engine.Connection getProtonConnection()
public AmqpProvider getProvider()
getProvider in interface AmqpResourceParentpublic ScheduledFuture<?> scheduleRequestTimeout(AsyncResult request, long timeout, ProviderException error)
Future instance that
can be used to cancel the scheduled automatic failure of the request.request - The request that should be marked as failed based on configuration.timeout - The time to wait before marking the request as failed.error - The error to use when failing the pending request.ScheduledFuture that can be stored by the caller.public ScheduledFuture<?> scheduleRequestTimeout(AsyncResult request, long timeout, AmqpExceptionBuilder builder)
Future instance that
can be used to cancel the scheduled automatic failure of the request.request - The request that should be marked as failed based on configuration.timeout - The time to wait before marking the request as failed.builder - An AmqpExceptionBuilder to use when creating a timed out exception.ScheduledFuture that can be stored by the caller.Copyright © 2013–2019 The Apache Software Foundation. All rights reserved.