Package org.apache.qpid.jms
Class JmsConnection
java.lang.Object
org.apache.qpid.jms.JmsConnection
- All Implemented Interfaces:
jakarta.jms.Connection,jakarta.jms.QueueConnection,jakarta.jms.TopicConnection,AutoCloseable,ProviderListener
- Direct Known Subclasses:
JmsQueueConnection,JmsTopicConnection
public class JmsConnection
extends Object
implements AutoCloseable, jakarta.jms.Connection, jakarta.jms.TopicConnection, jakarta.jms.QueueConnection, ProviderListener
Implementation of a JMS Connection
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJmsConnection(JmsConnectionInfo connectionInfo, Provider provider) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddConnectionConsumer(JmsConsumerInfo consumerInfo, JmsConnectionConsumer consumer) voidaddConnectionListener(JmsConnectionListener listener) Adds a JmsConnectionListener so that a client can be notified of events in the underlying connection and its state.protected voidaddSession(JmsSessionInfo sessionInfo, JmsSession session) protected voidprotected voidprotected voidvoidclose()jakarta.jms.ConnectionConsumercreateConnectionConsumer(jakarta.jms.Destination destination, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.ConnectionConsumercreateConnectionConsumer(jakarta.jms.Queue queue, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.ConnectionConsumercreateConnectionConsumer(jakarta.jms.Topic topic, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.ConnectionConsumercreateDurableConnectionConsumer(jakarta.jms.Topic topic, String subscriptionName, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.QueueSessioncreateQueueSession(boolean transacted, int acknowledgeMode) jakarta.jms.Sessionjakarta.jms.SessioncreateSession(boolean transacted, int acknowledgeMode) jakarta.jms.SessioncreateSession(int acknowledgeMode) jakarta.jms.ConnectionConsumercreateSharedConnectionConsumer(jakarta.jms.Topic topic, String subscriptionName, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) jakarta.jms.ConnectionConsumercreateSharedDurableConnectionConsumer(jakarta.jms.Topic topic, String subscriptionName, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) protected jakarta.jms.TemporaryQueueprotected jakarta.jms.TemporaryTopicjakarta.jms.TopicSessioncreateTopicSession(boolean transacted, int acknowledgeMode) protected voiddeleteTemporaryDestination(JmsTemporaryDestination destination) longlongjakarta.jms.ExceptionListenergetId()jakarta.jms.ConnectionMetaDataprotected JmsConsumerIdprotected JmsSessionIdprotected JmsTransactionIdlonglongprotected intgetSessionAcknowledgeMode(boolean transacted, int acknowledgeMode) booleanisClosed()booleanbooleanprotected booleanbooleanisFailed()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanprotected booleanisTemporaryDestinationDeleted(JmsDestination destination) booleanbooleanbooleanvoidonAsyncException(Throwable error) Handles any asynchronous errors that occur from the JMS framework classes.voidCalled 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.voidonConnectionEstablished(URI remoteURI) Called to indicate that the underlying connection to the Broker has been established for the first time.voidCalled to indicate that the underlying connection to the Broker has been lost and the Provider will not perform any reconnect.voidonConnectionInterrupted(URI remoteURI) Called from a fault tolerant Provider instance to signal that the underlying connection to the Broker has been lost.voidonConnectionRecovered(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.voidonConnectionRecovery(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.voidonConnectionRestored(URI remoteURI) Called to signal that all recovery operations are now complete and the Provider is again in a normal connected state.voidonException(jakarta.jms.JMSException ex) voidonException(Exception ex) voidonFailedMessageSend(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.voidonInboundMessage(JmsInboundMessageDispatch envelope) Called when a new Message has arrived for a registered consumer.voidCalled to indicate that a some client operation caused or received an error that is not considered fatal at the provider level.voidonResourceClosed(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.protected voidproviderFailed(ProviderException cause) protected voidremoveConnectionConsumer(JmsConsumerInfo consumerInfo) booleanRemoves a JmsConnectionListener that was previously registered.protected voidremoveSession(JmsSessionInfo sessionInfo) voidsetClientID(String clientID) voidsetCloseLinksThatFailOnReconnect(boolean closeLinksThatFailOnReconnect) voidsetCloseTimeout(long closeTimeout) voidsetConnectTimeout(long connectTimeout) voidsetDeserializationPolicy(JmsDeserializationPolicy deserializationPolicy) voidsetExceptionListener(jakarta.jms.ExceptionListener listener) voidsetForceAsyncAcks(boolean forceAsyncAcks) voidsetForceAsyncSend(boolean forceAsyncSend) voidsetForceSyncSend(boolean alwaysSyncSend) voidsetLocalMessageExpiry(boolean localMessageExpiry) voidsetLocalMessagePriority(boolean localMessagePriority) voidsetMessageIDPolicy(JmsMessageIDPolicy messageIDPolicy) voidsetPopulateJMSXUserID(boolean populateJMSXUserID) voidsetPrefetchPolicy(JmsPrefetchPolicy prefetchPolicy) voidsetPresettlePolicy(JmsPresettlePolicy presettlePolicy) voidsetQueuePrefix(String queuePrefix) voidsetReceiveLocalOnly(boolean receiveLocalOnly) voidsetReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly) voidsetRedeliveryPolicy(JmsRedeliveryPolicy redeliveryPolicy) voidsetRequestTimeout(long requestTimeout) voidsetSendTimeout(long sendTimeout) voidsetTopicPrefix(String topicPrefix) voidsetValidatePropertyNames(boolean validatePropertyNames) voidsetValidateSelector(boolean validateSelector) protected voidshutdown()Called to free all Connection resources.protected voidCalled to free all Connection resources.voidstart()voidstop()
-
Constructor Details
-
JmsConnection
protected JmsConnection(JmsConnectionInfo connectionInfo, Provider provider) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
-
Method Details
-
close
public void close() throws jakarta.jms.JMSException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
shutdown
protected void shutdown() throws jakarta.jms.JMSExceptionCalled to free all Connection resources.- Throws:
jakarta.jms.JMSException
-
shutdown
Called to free all Connection resources.- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession() throws jakarta.jms.JMSException- Specified by:
createSessionin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession(int acknowledgeMode) throws jakarta.jms.JMSException - Specified by:
createSessionin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
createSession
public jakarta.jms.Session createSession(boolean transacted, int acknowledgeMode) throws jakarta.jms.JMSException - Specified by:
createSessionin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
getClientID
- Specified by:
getClientIDin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
getMetaData
public jakarta.jms.ConnectionMetaData getMetaData() throws jakarta.jms.JMSException- Specified by:
getMetaDatain interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
setClientID
- Specified by:
setClientIDin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
start
public void start() throws jakarta.jms.JMSException- Specified by:
startin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
stop
public void stop() throws jakarta.jms.JMSException- Specified by:
stopin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
createDurableConnectionConsumer
public jakarta.jms.ConnectionConsumer createDurableConnectionConsumer(jakarta.jms.Topic topic, String subscriptionName, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createDurableConnectionConsumerin interfacejakarta.jms.Connection- Specified by:
createDurableConnectionConsumerin interfacejakarta.jms.TopicConnection- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Destination destination, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumerin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Topic topic, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumerin interfacejakarta.jms.TopicConnection- Throws:
jakarta.jms.JMSException
-
createConnectionConsumer
public jakarta.jms.ConnectionConsumer createConnectionConsumer(jakarta.jms.Queue queue, String messageSelector, jakarta.jms.ServerSessionPool sessionPool, int maxMessages) throws jakarta.jms.JMSException - Specified by:
createConnectionConsumerin interfacejakarta.jms.QueueConnection- Throws:
jakarta.jms.JMSException
-
createTopicSession
public jakarta.jms.TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws jakarta.jms.JMSException - Specified by:
createTopicSessionin interfacejakarta.jms.TopicConnection- Throws:
jakarta.jms.JMSException
-
createQueueSession
public jakarta.jms.QueueSession createQueueSession(boolean transacted, int acknowledgeMode) throws jakarta.jms.JMSException - Specified by:
createQueueSessionin interfacejakarta.jms.QueueConnection- Throws:
jakarta.jms.JMSException
-
onException
-
onException
public void onException(jakarta.jms.JMSException ex) -
getSessionAcknowledgeMode
protected int getSessionAcknowledgeMode(boolean transacted, int acknowledgeMode) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
removeSession
-
addSession
-
removeConnectionConsumer
-
addConnectionConsumer
-
createTemporaryQueue
protected jakarta.jms.TemporaryQueue createTemporaryQueue() throws jakarta.jms.JMSException- Returns:
- a newly initialized TemporaryQueue instance.
- Throws:
jakarta.jms.JMSException
-
createTemporaryTopic
protected jakarta.jms.TemporaryTopic createTemporaryTopic() throws jakarta.jms.JMSException- Returns:
- a newly initialized TemporaryTopic instance.
- Throws:
jakarta.jms.JMSException
-
deleteTemporaryDestination
protected void deleteTemporaryDestination(JmsTemporaryDestination destination) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
checkClosedOrFailed
protected void checkClosedOrFailed() throws jakarta.jms.JMSException- Throws:
jakarta.jms.JMSException
-
checkConsumeFromTemporaryDestination
protected void checkConsumeFromTemporaryDestination(JmsTemporaryDestination destination) throws jakarta.jms.JMSException - Throws:
jakarta.jms.JMSException
-
isTemporaryDestinationDeleted
-
checkClosed
protected void checkClosed() throws jakarta.jms.IllegalStateException- Throws:
jakarta.jms.IllegalStateException
-
getNextSessionId
-
getNextTransactionId
-
getNextConnectionConsumerId
-
isExplicitClientID
protected boolean isExplicitClientID() -
getExceptionListener
public jakarta.jms.ExceptionListener getExceptionListener() throws jakarta.jms.JMSException- Specified by:
getExceptionListenerin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
setExceptionListener
public void setExceptionListener(jakarta.jms.ExceptionListener listener) throws jakarta.jms.JMSException - Specified by:
setExceptionListenerin interfacejakarta.jms.Connection- Throws:
jakarta.jms.JMSException
-
addConnectionListener
Adds a JmsConnectionListener so that a client can be notified of events in the underlying connection and its state.- Parameters:
listener- the new listener to add to the collection.
-
removeConnectionListener
Removes a JmsConnectionListener that was previously registered.- Parameters:
listener- the listener to remove from the collection.- Returns:
- true if the given listener was removed from the current set.
-
isForceAsyncSend
public boolean isForceAsyncSend() -
setForceAsyncSend
public void setForceAsyncSend(boolean forceAsyncSend) -
isForceSyncSend
public boolean isForceSyncSend() -
setForceSyncSend
public void setForceSyncSend(boolean alwaysSyncSend) -
getTopicPrefix
-
setTopicPrefix
-
getQueuePrefix
-
setQueuePrefix
-
isValidatePropertyNames
public boolean isValidatePropertyNames() -
setValidatePropertyNames
public void setValidatePropertyNames(boolean validatePropertyNames) -
isValidateSelector
public boolean isValidateSelector() -
setValidateSelector
public void setValidateSelector(boolean validateSelector) -
getPrefetchPolicy
-
setPrefetchPolicy
-
getRedeliveryPolicy
-
setRedeliveryPolicy
-
getPresettlePolicy
-
setPresettlePolicy
-
getDeserializationPolicy
-
setDeserializationPolicy
-
isReceiveLocalOnly
public boolean isReceiveLocalOnly() -
setReceiveLocalOnly
public void setReceiveLocalOnly(boolean receiveLocalOnly) -
isReceiveNoWaitLocalOnly
public boolean isReceiveNoWaitLocalOnly() -
setReceiveNoWaitLocalOnly
public void setReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly) -
isLocalMessagePriority
public boolean isLocalMessagePriority() -
setLocalMessagePriority
public void setLocalMessagePriority(boolean localMessagePriority) -
getCloseTimeout
public long getCloseTimeout() -
setCloseTimeout
public void setCloseTimeout(long closeTimeout) -
getConnectTimeout
public long getConnectTimeout() -
setConnectTimeout
public void setConnectTimeout(long connectTimeout) -
getSendTimeout
public long getSendTimeout() -
setSendTimeout
public void setSendTimeout(long sendTimeout) -
getRequestTimeout
public long getRequestTimeout() -
setRequestTimeout
public void setRequestTimeout(long requestTimeout) -
getConfiguredURI
-
getConnectedURI
-
getUsername
-
getPassword
-
isConnected
public boolean isConnected() -
isStarted
public boolean isStarted() -
isClosed
public boolean isClosed() -
isFailed
public boolean isFailed() -
getId
-
getMessageFactory
-
isForceAsyncAcks
public boolean isForceAsyncAcks() -
setForceAsyncAcks
public void setForceAsyncAcks(boolean forceAsyncAcks) -
isLocalMessageExpiry
public boolean isLocalMessageExpiry() -
setLocalMessageExpiry
public void setLocalMessageExpiry(boolean localMessageExpiry) -
getMessageIDPolicy
-
setMessageIDPolicy
-
isPopulateJMSXUserID
public boolean isPopulateJMSXUserID() -
setPopulateJMSXUserID
public void setPopulateJMSXUserID(boolean populateJMSXUserID) -
isUseDaemonThread
public boolean isUseDaemonThread() -
isCloseLinksThatFailOnReconnect
public boolean isCloseLinksThatFailOnReconnect() -
setCloseLinksThatFailOnReconnect
public void setCloseLinksThatFailOnReconnect(boolean closeLinksThatFailOnReconnect) -
onInboundMessage
Description copied from interface:ProviderListenerCalled when a new Message has arrived for a registered consumer.- Specified by:
onInboundMessagein interfaceProviderListener- Parameters:
envelope- The dispatch object containing the message and delivery information.
-
onCompletedMessageSend
Description copied from interface:ProviderListenerCalled 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.- Specified by:
onCompletedMessageSendin interfaceProviderListener- Parameters:
envelope- the original outbound message dispatch that is now complete.
-
onFailedMessageSend
Description copied from interface:ProviderListenerCalled when an outbound message dispatch that requested a completion callback has reached a state where the send can be considered failed.- Specified by:
onFailedMessageSendin interfaceProviderListener- Parameters:
envelope- the original outbound message dispatch that should be treated as a failed send.cause- the exception that describes the cause of the failed send.
-
onConnectionInterrupted
Description copied from interface:ProviderListenerCalled from a fault tolerant Provider instance to signal that the underlying connection to the Broker has been lost. The Provider will attempt to reconnect following this event unless closed. It is considered a programming error to allow any exceptions to be thrown from this notification method.- Specified by:
onConnectionInterruptedin interfaceProviderListener- Parameters:
remoteURI- The URI of the Broker whose connection was lost.
-
onConnectionRecovery
Description copied from interface:ProviderListenerCalled to indicate that a connection to the Broker has been reestablished and that notified listener should start to recover it's state. The provider will not transition to the recovered state until the listener notifies the provider that recovery is complete.- Specified by:
onConnectionRecoveryin interfaceProviderListener- Parameters:
provider- The new Provider instance that will become active after the state has been recovered.- Throws:
Exception- if an error occurs during recovery attempt, this will fail the Provider that's being used for recovery.
-
onConnectionRecovered
Description copied from interface:ProviderListenerCalled 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. This method gives the listener a chance so send any necessary post recovery commands such as consumer start or message pull for a zero prefetch consumer etc.- Specified by:
onConnectionRecoveredin interfaceProviderListener- Parameters:
provider- The new Provider instance that will become active after the state has been recovered.- Throws:
Exception- if an error occurs during recovery attempt, this will fail the Provider that's being used for recovery.
-
onConnectionRestored
Description copied from interface:ProviderListenerCalled to signal that all recovery operations are now complete and the Provider is again in a normal connected state. It is considered a programming error to allow any exceptions to be thrown from this notification method.- Specified by:
onConnectionRestoredin interfaceProviderListener- Parameters:
remoteURI- The URI of the Broker that the client has now connected to.
-
onConnectionEstablished
Description copied from interface:ProviderListenerCalled to indicate that the underlying connection to the Broker has been established for the first time. For a fault tolerant provider this event should only ever be triggered once with the interruption and recovery events following on for future- Specified by:
onConnectionEstablishedin interfaceProviderListener- Parameters:
remoteURI- The URI of the Broker that the client has now connected to.
-
onConnectionFailure
Description copied from interface:ProviderListenerCalled to indicate that the underlying connection to the Broker has been lost and the Provider will not perform any reconnect. Following this call the provider is in a failed state and further calls to it will throw an Exception.- Specified by:
onConnectionFailurein interfaceProviderListener- Parameters:
ex- The exception that indicates the cause of this Provider failure.
-
onResourceClosed
Description copied from interface:ProviderListenerCalled to indicate that a currently active resource has been closed due to some error condition, management request or some other action. This can either be initiated remotely or locally depending on the condition that triggers the close.- Specified by:
onResourceClosedin interfaceProviderListener- Parameters:
resource- the JmsResource instance that has been closed.cause- optional exception object that indicates the cause of the close.
-
onProviderException
Description copied from interface:ProviderListenerCalled to indicate that a some client operation caused or received an error that is not considered fatal at the provider level.- Specified by:
onProviderExceptionin interfaceProviderListener- Parameters:
cause- the exception object that is being reported to the listener.
-
onAsyncException
Handles any asynchronous errors that occur from the JMS framework classes. If any listeners are registered they will be notified of the error from a thread in the Connection's Executor service.- Parameters:
error- The exception that triggered this error.
-
providerFailed
-