public class JmsConnection extends Object implements AutoCloseable, javax.jms.Connection, javax.jms.TopicConnection, javax.jms.QueueConnection, ProviderListener
Modifier | Constructor and Description |
---|---|
protected |
JmsConnection(String connectionId,
Provider provider,
IdGenerator clientIdGenerator) |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionListener(JmsConnectionListener listener)
Adds a JmsConnectionListener so that a client can be notified of events in
the underlying connection and its state.
|
protected void |
addSession(JmsSessionInfo sessionInfo,
JmsSession session) |
protected void |
checkClosed() |
protected void |
checkClosedOrFailed() |
protected void |
checkConsumeFromTemporaryDestination(JmsTemporaryDestination destination) |
void |
close() |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Destination destination,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Queue queue,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createConnectionConsumer(javax.jms.Topic topic,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.ConnectionConsumer |
createDurableConnectionConsumer(javax.jms.Topic topic,
String subscriptionName,
String messageSelector,
javax.jms.ServerSessionPool sessionPool,
int maxMessages) |
javax.jms.QueueSession |
createQueueSession(boolean transacted,
int acknowledgeMode) |
javax.jms.Session |
createSession(boolean transacted,
int acknowledgeMode) |
protected javax.jms.TemporaryQueue |
createTemporaryQueue() |
protected javax.jms.TemporaryTopic |
createTemporaryTopic() |
javax.jms.TopicSession |
createTopicSession(boolean transacted,
int acknowledgeMode) |
protected void |
deleteTemporaryDestination(JmsTemporaryDestination destination) |
String |
getClientID() |
long |
getCloseTimeout() |
URI |
getConfiguredURI() |
URI |
getConnectedURI() |
long |
getConnectTimeout() |
JmsDeserializationPolicy |
getDeserializationPolicy() |
javax.jms.ExceptionListener |
getExceptionListener() |
JmsConnectionId |
getId() |
JmsMessageFactory |
getMessageFactory() |
JmsMessageIDPolicy |
getMessageIDPolicy() |
javax.jms.ConnectionMetaData |
getMetaData() |
protected JmsSessionId |
getNextSessionId() |
protected JmsTransactionId |
getNextTransactionId() |
String |
getPassword() |
JmsPrefetchPolicy |
getPrefetchPolicy() |
JmsPresettlePolicy |
getPresettlePolicy() |
String |
getQueuePrefix() |
JmsRedeliveryPolicy |
getRedeliveryPolicy() |
long |
getRequestTimeout() |
long |
getSendTimeout() |
protected int |
getSessionAcknowledgeMode(boolean transacted,
int acknowledgeMode) |
String |
getTopicPrefix() |
String |
getUsername() |
boolean |
isClosed() |
boolean |
isConnected() |
protected boolean |
isExplicitClientID() |
boolean |
isFailed() |
boolean |
isForceAsyncAcks() |
boolean |
isForceAsyncSend() |
boolean |
isForceSyncSend() |
boolean |
isLocalMessageExpiry() |
boolean |
isLocalMessagePriority() |
boolean |
isPopulateJMSXUserID() |
boolean |
isReceiveLocalOnly() |
boolean |
isReceiveNoWaitLocalOnly() |
boolean |
isStarted() |
protected boolean |
isTemporaryDestinationDeleted(JmsDestination destination) |
boolean |
isValidatePropertyNames() |
void |
onAsyncException(Throwable error)
Handles any asynchronous errors that occur from the JMS framework classes.
|
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 |
onException(Exception ex) |
void |
onException(javax.jms.JMSException ex) |
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 |
onResourceClosed(JmsResource resource,
Exception cause)
Called to indicate that a currently active resource has been closed
due to some error condition, management request or some other action.
|
protected void |
providerFailed(IOException error) |
boolean |
removeConnectionListener(JmsConnectionListener listener)
Removes a JmsConnectionListener that was previously registered.
|
protected void |
removeSession(JmsSessionInfo sessionInfo) |
void |
setClientID(String clientID) |
void |
setCloseTimeout(long closeTimeout) |
void |
setConnectTimeout(long connectTimeout) |
void |
setDeserializationPolicy(JmsDeserializationPolicy deserializationPolicy) |
void |
setExceptionListener(javax.jms.ExceptionListener listener) |
void |
setForceAsyncAcks(boolean forceAsyncAcks) |
void |
setForceAsyncSend(boolean forceAsyncSend) |
void |
setForceSyncSend(boolean alwaysSyncSend) |
void |
setLocalMessageExpiry(boolean localMessageExpiry) |
void |
setLocalMessagePriority(boolean localMessagePriority) |
void |
setMessageIDPolicy(JmsMessageIDPolicy messageIDPolicy) |
void |
setPopulateJMSXUserID(boolean populateJMSXUserID) |
void |
setPrefetchPolicy(JmsPrefetchPolicy prefetchPolicy) |
void |
setPresettlePolicy(JmsPresettlePolicy presettlePolicy) |
void |
setQueuePrefix(String queuePrefix) |
void |
setReceiveLocalOnly(boolean receiveLocalOnly) |
void |
setReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly) |
void |
setRedeliveryPolicy(JmsRedeliveryPolicy redeliveryPolicy) |
void |
setRequestTimeout(long requestTimeout) |
void |
setSendTimeout(long sendTimeout) |
void |
setTopicPrefix(String topicPrefix) |
void |
setValidatePropertyNames(boolean validatePropertyNames) |
protected void |
shutdown()
Called to free all Connection resources.
|
protected void |
shutdown(Exception cause)
Called to free all Connection resources.
|
void |
start() |
void |
stop() |
protected JmsConnection(String connectionId, Provider provider, IdGenerator clientIdGenerator) throws javax.jms.JMSException
javax.jms.JMSException
public void close() throws javax.jms.JMSException
close
in interface AutoCloseable
close
in interface javax.jms.Connection
javax.jms.JMSException
protected void shutdown() throws javax.jms.JMSException
javax.jms.JMSException
protected void shutdown(Exception cause) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.Session createSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
createSession
in interface javax.jms.Connection
javax.jms.JMSException
public String getClientID() throws javax.jms.JMSException
getClientID
in interface javax.jms.Connection
javax.jms.JMSException
public javax.jms.ConnectionMetaData getMetaData() throws javax.jms.JMSException
getMetaData
in interface javax.jms.Connection
javax.jms.JMSException
public void setClientID(String clientID) throws javax.jms.JMSException
setClientID
in interface javax.jms.Connection
javax.jms.JMSException
public void start() throws javax.jms.JMSException
start
in interface javax.jms.Connection
javax.jms.JMSException
public void stop() throws javax.jms.JMSException
stop
in interface javax.jms.Connection
javax.jms.JMSException
public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, String subscriptionName, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createDurableConnectionConsumer
in interface javax.jms.Connection
createDurableConnectionConsumer
in interface javax.jms.TopicConnection
javax.jms.JMSException
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.Connection
javax.jms.JMSException
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.TopicConnection
javax.jms.JMSException
public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue, String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages) throws javax.jms.JMSException
createConnectionConsumer
in interface javax.jms.QueueConnection
javax.jms.JMSException
public javax.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
createTopicSession
in interface javax.jms.TopicConnection
javax.jms.JMSException
public javax.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
createQueueSession
in interface javax.jms.QueueConnection
javax.jms.JMSException
public void onException(Exception ex)
public void onException(javax.jms.JMSException ex)
protected int getSessionAcknowledgeMode(boolean transacted, int acknowledgeMode) throws javax.jms.JMSException
javax.jms.JMSException
protected void removeSession(JmsSessionInfo sessionInfo) throws javax.jms.JMSException
javax.jms.JMSException
protected void addSession(JmsSessionInfo sessionInfo, JmsSession session)
protected javax.jms.TemporaryQueue createTemporaryQueue() throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.TemporaryTopic createTemporaryTopic() throws javax.jms.JMSException
javax.jms.JMSException
protected void deleteTemporaryDestination(JmsTemporaryDestination destination) throws javax.jms.JMSException
javax.jms.JMSException
protected void checkClosedOrFailed() throws javax.jms.JMSException
javax.jms.JMSException
protected void checkConsumeFromTemporaryDestination(JmsTemporaryDestination destination) throws javax.jms.JMSException
javax.jms.JMSException
protected boolean isTemporaryDestinationDeleted(JmsDestination destination)
protected void checkClosed() throws javax.jms.IllegalStateException
javax.jms.IllegalStateException
protected JmsSessionId getNextSessionId()
protected JmsTransactionId getNextTransactionId()
protected boolean isExplicitClientID()
public javax.jms.ExceptionListener getExceptionListener() throws javax.jms.JMSException
getExceptionListener
in interface javax.jms.Connection
javax.jms.JMSException
public void setExceptionListener(javax.jms.ExceptionListener listener) throws javax.jms.JMSException
setExceptionListener
in interface javax.jms.Connection
javax.jms.JMSException
public void addConnectionListener(JmsConnectionListener listener)
listener
- the new listener to add to the collection.public boolean removeConnectionListener(JmsConnectionListener listener)
listener
- the listener to remove from the collection.public boolean isForceAsyncSend()
public void setForceAsyncSend(boolean forceAsyncSend)
public boolean isForceSyncSend()
public void setForceSyncSend(boolean alwaysSyncSend)
public String getTopicPrefix()
public void setTopicPrefix(String topicPrefix)
public String getQueuePrefix()
public void setQueuePrefix(String queuePrefix)
public boolean isValidatePropertyNames()
public void setValidatePropertyNames(boolean validatePropertyNames)
public JmsPrefetchPolicy getPrefetchPolicy()
public void setPrefetchPolicy(JmsPrefetchPolicy prefetchPolicy)
public JmsRedeliveryPolicy getRedeliveryPolicy()
public void setRedeliveryPolicy(JmsRedeliveryPolicy redeliveryPolicy)
public JmsPresettlePolicy getPresettlePolicy()
public void setPresettlePolicy(JmsPresettlePolicy presettlePolicy)
public JmsDeserializationPolicy getDeserializationPolicy()
public void setDeserializationPolicy(JmsDeserializationPolicy deserializationPolicy)
public boolean isReceiveLocalOnly()
public void setReceiveLocalOnly(boolean receiveLocalOnly)
public boolean isReceiveNoWaitLocalOnly()
public void setReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly)
public boolean isLocalMessagePriority()
public void setLocalMessagePriority(boolean localMessagePriority)
public long getCloseTimeout()
public void setCloseTimeout(long closeTimeout)
public long getConnectTimeout()
public void setConnectTimeout(long connectTimeout)
public long getSendTimeout()
public void setSendTimeout(long sendTimeout)
public long getRequestTimeout()
public void setRequestTimeout(long requestTimeout)
public URI getConfiguredURI()
public URI getConnectedURI()
public String getUsername()
public String getPassword()
public boolean isConnected()
public boolean isStarted()
public boolean isClosed()
public boolean isFailed()
public JmsConnectionId getId()
public JmsMessageFactory getMessageFactory()
public boolean isForceAsyncAcks()
public void setForceAsyncAcks(boolean forceAsyncAcks)
public boolean isLocalMessageExpiry()
public void setLocalMessageExpiry(boolean localMessageExpiry)
public JmsMessageIDPolicy getMessageIDPolicy()
public void setMessageIDPolicy(JmsMessageIDPolicy messageIDPolicy)
public boolean isPopulateJMSXUserID()
public void setPopulateJMSXUserID(boolean populateJMSXUserID)
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 onResourceClosed(JmsResource resource, Exception cause)
ProviderListener
onResourceClosed
in interface ProviderListener
resource
- the JmsResource instance that has been 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 void onAsyncException(Throwable error)
error
- The exception that triggered this error.protected void providerFailed(IOException error)
Copyright © 2013–2016 The Apache Software Foundation. All rights reserved.