public class JmsConnectionFactory extends JNDIStorable implements javax.jms.ConnectionFactory, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory
| Modifier and Type | Field and Description |
|---|---|
static String |
REMOTE_URI_PROP |
| Constructor and Description |
|---|
JmsConnectionFactory() |
JmsConnectionFactory(String remoteURI) |
JmsConnectionFactory(String username,
String password) |
JmsConnectionFactory(String userName,
String password,
String remoteURI) |
JmsConnectionFactory(String userName,
String password,
URI remoteURI) |
JmsConnectionFactory(URI remoteURI) |
| Modifier and Type | Method and Description |
|---|---|
protected Map<String,String> |
buildFromProperties(Map<String,String> props)
Set the properties that will represent the instance in JNDI
|
protected JmsConnectionInfo |
configureConnectionInfo(String username,
String password) |
javax.jms.Connection |
createConnection() |
javax.jms.Connection |
createConnection(String username,
String password) |
javax.jms.JMSContext |
createContext() |
javax.jms.JMSContext |
createContext(int sessionMode) |
javax.jms.JMSContext |
createContext(String username,
String password) |
javax.jms.JMSContext |
createContext(String username,
String password,
int sessionMode) |
protected Provider |
createProvider(URI remoteURI) |
javax.jms.QueueConnection |
createQueueConnection() |
javax.jms.QueueConnection |
createQueueConnection(String username,
String password) |
javax.jms.TopicConnection |
createTopicConnection() |
javax.jms.TopicConnection |
createTopicConnection(String username,
String password) |
protected static URI |
createURI(String name) |
String |
getClientID() |
protected IdGenerator |
getClientIdGenerator() |
String |
getClientIDPrefix() |
long |
getCloseTimeout()
Gets the currently set close timeout.
|
protected IdGenerator |
getConnectionIdGenerator() |
long |
getConnectTimeout()
Returns the currently configured wire level connect timeout.
|
static String |
getDefaultRemoteAddress() |
JmsDeserializationPolicy |
getDeserializationPolicy() |
javax.jms.ExceptionListener |
getExceptionListener()
Gets the currently configured JMS ExceptionListener that will be set on all
new Connection objects created from this factory.
|
JmsMessageIDPolicy |
getMessageIDPolicy() |
String |
getPassword() |
JmsPrefetchPolicy |
getPrefetchPolicy() |
JmsPresettlePolicy |
getPresettlePolicy() |
String |
getQueuePrefix()
Returns the prefix applied to Queues that are created by the client.
|
JmsRedeliveryPolicy |
getRedeliveryPolicy()
Returns the JmsRedeliveryPolicy that is applied when a new connection is created.
|
String |
getRemoteURI() |
long |
getRequestTimeout() |
long |
getSendTimeout() |
String |
getTopicPrefix()
Returns the prefix applied to Topics that are created by the client.
|
JmsTracer |
getTracer()
Gets any tracer previously set explicitly on the connection factory using
setTracer(JmsTracer). |
String |
getTracing() |
String |
getUsername() |
boolean |
isAwaitClientID() |
boolean |
isCloseLinksThatFailOnReconnect() |
boolean |
isForceAsyncAcks() |
boolean |
isForceAsyncSend() |
boolean |
isForceSyncSend()
Returns true if the client should always send messages using a synchronous
send operation regardless of persistence mode, or inside a transaction.
|
boolean |
isLocalMessageExpiry() |
boolean |
isLocalMessagePriority() |
boolean |
isPopulateJMSXUserID() |
boolean |
isReceiveLocalOnly() |
boolean |
isReceiveNoWaitLocalOnly() |
boolean |
isUseDaemonThread() |
boolean |
isValidatePropertyNames() |
protected void |
populateProperties(Map<String,String> props)
Initialize the instance from properties stored in JNDI
|
void |
setAwaitClientID(boolean awaitClientID)
Controls whether the client will wait for a ClientID value to be set or the Connection
to be used before it will attempt to complete the AMQP connection Open process.
|
void |
setClientID(String clientID)
Sets the JMS clientID to use for connections created by this factory.
|
protected void |
setClientIdGenerator(IdGenerator clientIdGenerator) |
void |
setClientIDPrefix(String clientIDPrefix)
Sets the prefix used by auto-generated JMS Client ID values which are used if the JMS
client does not explicitly specify one.
|
void |
setCloseLinksThatFailOnReconnect(boolean closeLinksThatFailOnReconnect)
Controls how the client manages errors on recreation of a link (producer / consumer) during
a failover reconnect attempt (defaults to false).
|
void |
setCloseTimeout(long closeTimeout)
Sets the close timeout used to control how long a Connection close will wait for
clean shutdown of the connection before giving up.
|
protected void |
setConnectionIdGenerator(IdGenerator connectionIdGenerator) |
void |
setConnectionIDPrefix(String connectionIDPrefix)
Sets the prefix used by connection id generator.
|
void |
setConnectTimeout(long connectTimeout)
Sets the timeout value used to control how long a client will wait for a successful
connection to the remote peer to be established before considering the attempt to
have failed.
|
void |
setDeserializationPolicy(JmsDeserializationPolicy deserializationPolicy)
Sets the JmsDeserializationPolicy that is applied when a new connection is created.
|
void |
setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Sets the JMS ExceptionListener that will be set on all new Connection objects
created from this factory.
|
void |
setExtension(String extensionName,
BiFunction<javax.jms.Connection,URI,Object> extension)
Provides an entry point for extensions to be configured on this
ConnectionFactory. |
void |
setForceAsyncAcks(boolean forceAsyncAcks)
Should the message acknowledgments from a consumer be sent synchronously or
asynchronously.
|
void |
setForceAsyncSend(boolean forceAsyncSend) |
void |
setForceSyncSend(boolean forceSyncSend)
Configures whether or not the client will always send messages synchronously or not
regardless of other factors that might result in an asynchronous send.
|
void |
setLocalMessageExpiry(boolean localMessageExpiry)
Controls whether message expiration checking is done locally (in addition to any broker
side checks) in each MessageConsumer prior to dispatching a message.
|
void |
setLocalMessagePriority(boolean localMessagePriority)
Enables client-side message priority support in MessageConsumer instances.
|
void |
setMessageIDPolicy(JmsMessageIDPolicy messageIDPolicy)
Sets the JmsMessageIDPolicy that is use to configure the JmsMessageIDBuilder
that is assigned to any new MessageProducer created from Connection instances
that this factory has created.
|
void |
setPassword(String password) |
void |
setPopulateJMSXUserID(boolean populateJMSXUserID)
Controls whether message sent from the Connection will have the JMSXUserID message
property populated with the authenticated user ID of the Connection.
|
void |
setPrefetchPolicy(JmsPrefetchPolicy prefetchPolicy) |
void |
setPresettlePolicy(JmsPresettlePolicy presettlePolicy)
Sets the JmsPresettlePolicy that is applied to MessageProducers.
|
void |
setQueuePrefix(String queuePrefix) |
void |
setReceiveLocalOnly(boolean receiveLocalOnly)
Controls whether the client only checks its local message buffer when using
receive calls with a timeout, or will instead drain remaining credit from the
remote peer to ensure there are really no messages available if the
timeout expires before a message arrives in the consumers local buffer.
|
void |
setReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly)
Controls whether the client only checks its local message buffer when using
receiveNoWait calls, or will instead drain remaining credit from the
remote peer synchronously to ensure there are really no messages available
that have yet to arrive in the consumers local buffer.
|
void |
setRedeliveryPolicy(JmsRedeliveryPolicy redeliveryPolicy)
Sets the JmsRedeliveryPolicy that is applied when a new connection is created.
|
void |
setRemoteURI(String remoteURI) |
void |
setRequestTimeout(long requestTimeout) |
void |
setSendTimeout(long sendTimeout) |
void |
setSslContext(SSLContext sslContext)
Sets an SSLContext to use when creating an SSL/TLS secured connection with this factory.
|
void |
setTopicPrefix(String topicPrefix) |
void |
setTracer(JmsTracer tracer)
Explicitly sets a tracer instance for use by the connection(s) created from the factory.
|
void |
setTracing(String tracing)
Sets the type name for a tracing provider to use for the connection(s) created using the factory.
|
void |
setUseDaemonThread(boolean useDaemonThread)
Sets whether the Connection created will ensure that there is at least one non-daemon
thread running at all times.
|
void |
setUsername(String username) |
void |
setValidatePropertyNames(boolean validatePropertyNames) |
getProperties, getProperty, getReference, readExternal, setProperties, writeExternalpublic static final String REMOTE_URI_PROP
public JmsConnectionFactory()
public JmsConnectionFactory(String remoteURI)
public JmsConnectionFactory(String userName, String password, String remoteURI)
public JmsConnectionFactory(URI remoteURI)
protected Map<String,String> buildFromProperties(Map<String,String> props)
JNDIStorablebuildFromProperties in class JNDIStorableprops - The properties to use when building the new isntance.protected void populateProperties(Map<String,String> props)
JNDIStorablepopulateProperties in class JNDIStorableprops - The properties to use when initializing the new instance.public javax.jms.TopicConnection createTopicConnection()
throws javax.jms.JMSException
createTopicConnection in interface javax.jms.TopicConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.TopicConnection createTopicConnection(String username, String password) throws javax.jms.JMSException
createTopicConnection in interface javax.jms.TopicConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.Connection createConnection()
throws javax.jms.JMSException
createConnection in interface javax.jms.ConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.Connection createConnection(String username, String password) throws javax.jms.JMSException
createConnection in interface javax.jms.ConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.QueueConnection createQueueConnection()
throws javax.jms.JMSException
createQueueConnection in interface javax.jms.QueueConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.QueueConnection createQueueConnection(String username, String password) throws javax.jms.JMSException
createQueueConnection in interface javax.jms.QueueConnectionFactoryjavax.jms.JMSExceptionprotected JmsConnectionInfo configureConnectionInfo(String username, String password) throws javax.jms.JMSException
javax.jms.JMSExceptionpublic javax.jms.JMSContext createContext()
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(int sessionMode)
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(String username, String password)
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(String username, String password, int sessionMode)
createContext in interface javax.jms.ConnectionFactoryprotected IdGenerator getConnectionIdGenerator()
protected void setConnectionIdGenerator(IdGenerator connectionIdGenerator)
public String getRemoteURI()
public void setRemoteURI(String remoteURI)
remoteURI - the remoteURI to setpublic String getUsername()
public void setUsername(String username)
username - the user name to setpublic String getPassword()
public void setPassword(String password)
password - the password to setpublic boolean isForceSyncSend()
public void setForceSyncSend(boolean forceSyncSend)
forceSyncSend - if true sends are always done synchronously.public boolean isForceAsyncSend()
public void setForceAsyncSend(boolean forceAsyncSend)
public boolean isLocalMessagePriority()
public void setLocalMessagePriority(boolean localMessagePriority)
localMessagePriority - the messagePrioritySupported to setpublic String getQueuePrefix()
public void setQueuePrefix(String queuePrefix)
public String getTopicPrefix()
public void setTopicPrefix(String topicPrefix)
public boolean isValidatePropertyNames()
public void setValidatePropertyNames(boolean validatePropertyNames)
public long getCloseTimeout()
public void setCloseTimeout(long closeTimeout)
closeTimeout - time in milliseconds to wait for a clean connection close.public long getConnectTimeout()
public void setConnectTimeout(long connectTimeout)
connectTimeout - the time in milliseconds to wait for the protocol connection handshake to complete.public long getSendTimeout()
public void setSendTimeout(long sendTimeout)
public long getRequestTimeout()
public void setRequestTimeout(long requestTimeout)
public JmsPrefetchPolicy getPrefetchPolicy()
public void setPrefetchPolicy(JmsPrefetchPolicy prefetchPolicy)
public JmsRedeliveryPolicy getRedeliveryPolicy()
public void setRedeliveryPolicy(JmsRedeliveryPolicy redeliveryPolicy)
redeliveryPolicy - The new redeliveryPolicy to setpublic JmsPresettlePolicy getPresettlePolicy()
public void setPresettlePolicy(JmsPresettlePolicy presettlePolicy)
presettlePolicy - the presettlePolicy to use by connections created from this factory.public JmsMessageIDPolicy getMessageIDPolicy()
public void setMessageIDPolicy(JmsMessageIDPolicy messageIDPolicy)
messageIDPolicy - the messageIDPolicy to use by connections created from this factory.public JmsDeserializationPolicy getDeserializationPolicy()
public void setDeserializationPolicy(JmsDeserializationPolicy deserializationPolicy)
deserializationPolicy - the deserializationPolicy that will be applied to new connections.public String getClientIDPrefix()
public void setClientIDPrefix(String clientIDPrefix)
clientIDPrefix - the value to use as a prefix on auto-generated client IDs.protected IdGenerator getClientIdGenerator()
protected void setClientIdGenerator(IdGenerator clientIdGenerator)
public String getClientID()
public void setClientID(String clientID)
clientID - The clientID to assign when creating a new connection.public void setConnectionIDPrefix(String connectionIDPrefix)
connectionIDPrefix - The string prefix used on all connection Id's created by this factory.public javax.jms.ExceptionListener getExceptionListener()
public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
exceptionListener - the JMS ExceptionListener to apply to new Connection's or null to clear.public boolean isForceAsyncAcks()
public void setForceAsyncAcks(boolean forceAsyncAcks)
forceAsyncAcks - true to have the client send all message acknowledgments asynchronously.public boolean isLocalMessageExpiry()
public void setLocalMessageExpiry(boolean localMessageExpiry)
localMessageExpiry - controls whether expiration checking is done prior to dispatch.public boolean isReceiveLocalOnly()
public void setReceiveLocalOnly(boolean receiveLocalOnly)
receiveLocalOnly - true if receive calls with a timeout should only check the local message buffer.public boolean isReceiveNoWaitLocalOnly()
public void setReceiveNoWaitLocalOnly(boolean receiveNoWaitLocalOnly)
receiveNoWaitLocalOnly - true if receiveNoWait calls should only check the local message buffer.public boolean isPopulateJMSXUserID()
public void setPopulateJMSXUserID(boolean populateJMSXUserID)
populateJMSXUserID - true if message sent from this connection should have the JMSXUserID value populated.public void setSslContext(SSLContext sslContext)
sslContext - the sslContext to use, or null to respect the URI/System property configuration again.public boolean isAwaitClientID()
public void setAwaitClientID(boolean awaitClientID)
By default a newly created Connection that does not have a ClientID configured in the URI will wait until a call to setClientID or some other interaction with the Connection API occurs before finishing the AMQP connection Open process with the remote peer. In some cases if this takes too long the remote can disconnect as a way of defending against denial of service attacks. If the user does not plan on setting a ClientID then this option allows for immediate AMQP connection Open completion and avoids the case where the remote peer might drop the Connection if it isn't used promptly.
This value defaults to true.
awaitClientID - the whether to wait for the client ID to be set before activating the connection.public boolean isUseDaemonThread()
public void setUseDaemonThread(boolean useDaemonThread)
useDaemonThread - controls whether the Connection maintains a non-daemon thread.public boolean isCloseLinksThatFailOnReconnect()
public void setCloseLinksThatFailOnReconnect(boolean closeLinksThatFailOnReconnect)
When false the failure of a link recreation operation while reestablishing a failed connection
results in the client failing that reconnect attempt and retrying the entire connection process
again. This can be disabled by setting this option to true in which case the client will close
the producer or consumer associated with the failed link create attempt and continue rebuilding
the client resources for the newly reestablished connection. When failing a consumer link the
client will trigger the ExceptionListener assigned to the Connection if the link that failed
was a consumer and that consumer had an associated JMS MessageListener.
closeLinksThatFailOnReconnect - whether to close links that fail to establish on failover reconnect.public void setExtension(String extensionName, BiFunction<javax.jms.Connection,URI,Object> extension)
ConnectionFactory.
If a previous extension with the same name is present it is replaced with the new value or cleared if the value is null.
extensionName - The name of the extension point being added.extension - The Function that implements the extension.JmsConnectionExtensionspublic void setTracing(String tracing)
tracing - The tracing provider type name to setpublic String getTracing()
public void setTracer(JmsTracer tracer)
setTracing(String) method.
The provided tracer will have its close method called when a created connection/context is closed,
so if a tracer is to be used across multiple such connections created by this factory then the close
method should handle that appropriately, e.g no-op and have the application and/or underlying tracing
implementation cleanup at shutdown. If no Connection/JMSContext object is returned from a creation
attempt due to an exception being thrown, the tracer provided will not have its close method called
and the application or underlying tracing implementation is responsible for any cleanup required.tracer - The tracer to setpublic JmsTracer getTracer()
setTracer(JmsTracer).
Does not return any tracer created implicitly due to use of either URI configuration option
or the setTracing(String) method.public static String getDefaultRemoteAddress()
Copyright © 2013–2019 The Apache Software Foundation. All rights reserved.