public class RMQConnectionFactory
extends java.lang.Object
implements javax.jms.ConnectionFactory, javax.naming.Referenceable, java.io.Serializable, javax.jms.QueueConnectionFactory, javax.jms.TopicConnectionFactory
ConnectionFactory
TODO - implement SslContext option| Constructor and Description |
|---|
RMQConnectionFactory() |
| Modifier and Type | Method and Description |
|---|---|
javax.jms.Connection |
createConnection() |
javax.jms.Connection |
createConnection(java.util.List<com.rabbitmq.client.Address> endpoints) |
javax.jms.Connection |
createConnection(java.lang.String username,
java.lang.String password) |
javax.jms.Connection |
createConnection(java.lang.String username,
java.lang.String password,
java.util.List<com.rabbitmq.client.Address> endpoints) |
protected javax.jms.Connection |
createConnection(java.lang.String username,
java.lang.String password,
com.rabbitmq.jms.admin.RMQConnectionFactory.ConnectionCreator connectionCreator) |
protected com.rabbitmq.client.ConnectionFactory |
createConnectionFactory() |
javax.jms.JMSContext |
createContext() |
javax.jms.JMSContext |
createContext(int sessionMode) |
javax.jms.JMSContext |
createContext(java.lang.String username,
java.lang.String password) |
javax.jms.JMSContext |
createContext(java.lang.String username,
java.lang.String password,
int sessionMode) |
javax.jms.QueueConnection |
createQueueConnection() |
javax.jms.QueueConnection |
createQueueConnection(java.lang.String userName,
java.lang.String password) |
javax.jms.TopicConnection |
createTopicConnection() |
javax.jms.TopicConnection |
createTopicConnection(java.lang.String userName,
java.lang.String password) |
int |
getChannelsQos()
QoS setting for channels created by this connection factory.
|
java.lang.String |
getHost()
Returns the host name to be used when creating a connection to the RabbitMQ broker.
|
int |
getOnMessageTimeoutMs()
Returns the time in milliseconds
MessageListener.onMessage(Message) can take to process a message |
java.lang.String |
getPassword()
Returns the configured password used when creating a connection If
setPassword(String) has not been called the default value of 'guest' is returned. |
int |
getPort()
Returns the port the RabbitMQ broker listens to; this port is used to connect to the broker.
|
int |
getQueueBrowserReadMax()
Returns the maximum number of messages to read on a queue browser, or zero if there is no limit.
|
javax.naming.Reference |
getReference() |
long |
getTerminationTimeout()
Returns the time to wait in milliseconds when
Connection.close() has been called for listeners and threads to
complete. |
java.util.List<java.lang.String> |
getTrustedPackages() |
java.lang.String |
getUri()
Returns the current factory connection parameters in a URI String.
|
java.util.List<java.lang.String> |
getUris() |
java.lang.String |
getUsername()
Returns the configured username used when creating a connection If
setUsername(String) has not been called the default value of 'guest' is returned. |
java.lang.String |
getVirtualHost()
Returns the virtual host used when creating a connection.
|
boolean |
isCleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose() |
boolean |
isNackOnRollback() |
boolean |
isPreferProducerMessageProperty() |
boolean |
isRequeueOnMessageListenerException() |
boolean |
isSsl() |
boolean |
isUseDefaultSslContext()
Whether to use the default
SSLContext or not. |
void |
setAmqpConnectionFactoryPostProcessor(java.util.function.Consumer<com.rabbitmq.client.ConnectionFactory> amqpConnectionFactoryPostProcessor)
Set a post-processor for the AMQP
ConnectionFactory. |
void |
setAmqpPropertiesCustomiser(java.util.function.BiFunction<com.rabbitmq.client.AMQP.BasicProperties.Builder,javax.jms.Message,com.rabbitmq.client.AMQP.BasicProperties.Builder> amqpPropertiesCustomiser) |
void |
setChannelsQos(int channelsQos)
QoS setting for channels created by this connection factory.
|
void |
setCleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose(boolean cleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose) |
void |
setConfirmListener(ConfirmListener confirmListener)
Deprecated.
Use the
MessageProducer send methods with a CompletionListener |
void |
setDeclareReplyToDestination(boolean declareReplyToDestination)
Whether
replyTo destination for consumed messages should be declared. |
void |
setHost(java.lang.String host)
Sets the host of the RabbitMQ broker.
|
void |
setHostnameVerification(boolean hostnameVerification)
Enable or disable hostname verification when TLS is used.
|
void |
setKeepTextMessageType(boolean keepTextMessageType) |
void |
setMetricsCollector(com.rabbitmq.client.MetricsCollector metricsCollector)
Set the collector for AMQP-client metrics.
|
void |
setNackOnRollback(boolean nackOnRollback)
Whether to nack messages on rollback or not.
|
void |
setOnMessageTimeoutMs(int onMessageTimeoutMs)
Sets onMessageTimeoutMs: the time in milliseconds
MessageListener.onMessage(Message) can take to process a message. |
void |
setPassword(java.lang.String password)
Sets the password to be used when creating a connection to the RabbitMQ broker
|
void |
setPort(int port)
Set the port to be used when making a connection to the RabbitMQ broker.
|
void |
setPreferProducerMessageProperty(boolean preferProducerMessageProperty)
Whether
MessageProducer properties (delivery mode,
priority, TTL) take precedence over respective Message
properties or not. |
void |
setQueueBrowserReadMax(int queueBrowserReadMax)
Sets queueBrowserReadMax: the maximum number of messages to read on a queue browser.
|
void |
setReceivingContextConsumer(ReceivingContextConsumer receivingContextConsumer)
Set callback called before dispatching a received message to application code.
|
void |
setRequeueOnMessageListenerException(boolean requeueOnMessageListenerException)
Whether requeue message on
RuntimeException in the
MessageListener or not. |
void |
setRequeueOnTimeout(boolean requeueOnTimeout)
Whether to requeue a message that timed out or not.
|
void |
setSendingContextConsumer(SendingContextConsumer sendingContextConsumer)
Set callback called before sending a message.
|
void |
setSsl(boolean ssl)
Deprecated.
|
void |
setTerminationTimeout(long terminationTimeout)
Sets terminationTimeout: the time in milliseconds a
Connection.close() should wait for threads/tasks/listeners to complete |
void |
setTrustedPackages(java.util.List<java.lang.String> value) |
void |
setUri(java.lang.String uriString)
Set connection factory parameters by URI String.
|
void |
setUris(java.util.List<java.lang.String> urisAsStrings)
Sets the nodes URIs to connect to.
|
void |
setUseDefaultSslContext(boolean useDefaultSslContext)
Whether to use the default
SSLContext or not. |
void |
setUsername(java.lang.String username)
Sets the username to be used when creating a connection to the RabbitMQ broker.
|
void |
setValidateSubscriptionNames(boolean validateSubscriptionNames)
Whether to validate subscription names or not, according to JMS 2.0.
|
void |
setVirtualHost(java.lang.String virtualHost)
Sets the virtualHost to be used when creating a connection to the RabbitMQ broker.
|
java.lang.String |
toString() |
void |
useDefaultSslContext(boolean useDefaultSslContext)
Whether to use the default
SSLContext or not. |
void |
useSslProtocol()
Enables TLS on opened connections with the highest TLS
version available.
|
void |
useSslProtocol(javax.net.ssl.SSLContext context)
Enables TLS on opened connections using the provided
SSLContext. |
void |
useSslProtocol(java.lang.String protocol)
Enables TLS on opened connections using the provided TLS protocol
version.
|
public javax.jms.Connection createConnection()
throws javax.jms.JMSException
createConnection in interface javax.jms.ConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.Connection createConnection(java.util.List<com.rabbitmq.client.Address> endpoints)
throws javax.jms.JMSException
javax.jms.JMSExceptionpublic javax.jms.Connection createConnection(java.lang.String username,
java.lang.String password)
throws javax.jms.JMSException
createConnection in interface javax.jms.ConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.Connection createConnection(java.lang.String username,
java.lang.String password,
java.util.List<com.rabbitmq.client.Address> endpoints)
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected javax.jms.Connection createConnection(java.lang.String username,
java.lang.String password,
com.rabbitmq.jms.admin.RMQConnectionFactory.ConnectionCreator connectionCreator)
throws javax.jms.JMSException
javax.jms.JMSExceptionprotected com.rabbitmq.client.ConnectionFactory createConnectionFactory()
public java.lang.String getUri()
public java.lang.String toString()
toString in class java.lang.Objectpublic void setUri(java.lang.String uriString)
throws javax.jms.JMSException
uriString - URI to use for instantiated connectionjavax.jms.JMSException - if connection URI is invalidpublic void setUris(java.util.List<java.lang.String> urisAsStrings)
throws javax.jms.JMSException
urisAsStrings - javax.jms.JMSExceptionpublic void setTrustedPackages(java.util.List<java.lang.String> value)
value - list of trusted package prefixespublic java.util.List<java.lang.String> getTrustedPackages()
ObjectMessagepublic boolean isSsl()
@Deprecated public void setSsl(boolean ssl)
useSslProtocol(), useSslProtocol(String)
or useSslProtocol(SSLContext).ssl - if true, enables TLS for connections openedpublic void useSslProtocol()
throws java.security.NoSuchAlgorithmException
java.security.NoSuchAlgorithmException - see NoSuchAlgorithmExceptionpublic void useSslProtocol(java.lang.String protocol)
protocol - TLS or SSL protocol version.public void useSslProtocol(javax.net.ssl.SSLContext context)
SSLContext.context - SSLContext to usepublic void useDefaultSslContext(boolean useDefaultSslContext)
SSLContext or not.
Default is false.
When this option is enabled, the default SSLContext
will always be used and will override any other SSLContext
set.useDefaultSslContext - SSLContext.getDefault()public boolean isUseDefaultSslContext()
SSLContext or not.SSLContext.getDefault()public void setUseDefaultSslContext(boolean useDefaultSslContext)
SSLContext or not.
Default is false.
When this option is enabled, the default SSLContext
will always be used and will override any other SSLContext
set.useDefaultSslContext - SSLContext.getDefault()public javax.naming.Reference getReference()
throws javax.naming.NamingException
getReference in interface javax.naming.Referenceablejavax.naming.NamingExceptionpublic javax.jms.TopicConnection createTopicConnection()
throws javax.jms.JMSException
createTopicConnection in interface javax.jms.TopicConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.TopicConnection createTopicConnection(java.lang.String userName,
java.lang.String password)
throws javax.jms.JMSException
createTopicConnection in interface javax.jms.TopicConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.QueueConnection createQueueConnection()
throws javax.jms.JMSException
createQueueConnection in interface javax.jms.QueueConnectionFactoryjavax.jms.JMSExceptionpublic javax.jms.QueueConnection createQueueConnection(java.lang.String userName,
java.lang.String password)
throws javax.jms.JMSException
createQueueConnection in interface javax.jms.QueueConnectionFactoryjavax.jms.JMSExceptionpublic java.lang.String getUsername()
setUsername(String) has not been called the default value of 'guest' is returned.public void setUsername(java.lang.String username)
null the current username is not changed.username - - username to be used when creating a connection to the RabbitMQ brokerpublic java.lang.String getPassword()
setPassword(String) has not been called the default value of 'guest' is returned.public void setPassword(java.lang.String password)
password - - password to be used when creating a connection to the RabbitMQ brokerpublic java.lang.String getVirtualHost()
setVirtualHost(String) has not been called the default value of '/' is returned.public void setVirtualHost(java.lang.String virtualHost)
null the current virtualHost is not changed.virtualHost - - virtual host to be used when creating a connection to the RabbitMQ brokerpublic java.lang.String getHost()
public void setHost(java.lang.String host)
null the current host name is not changed.host - - IP address or a host name of the RabbitMQ broker, in String formpublic int getPort()
public void setPort(int port)
port - - a TCP port numberpublic long getTerminationTimeout()
Connection.close() has been called for listeners and threads to
complete.Connection.close() waits before continuing shutdown sequencepublic void setTerminationTimeout(long terminationTimeout)
Connection.close() should wait for threads/tasks/listeners to completeterminationTimeout - - duration in millisecondspublic int getQueueBrowserReadMax()
public void setQueueBrowserReadMax(int queueBrowserReadMax)
queueBrowserReadMax - - read no more than this number of messages on a queue browser.public int getOnMessageTimeoutMs()
MessageListener.onMessage(Message) can take to process a messageMessageListener.onMessage(Message) can take to process a messagepublic void setOnMessageTimeoutMs(int onMessageTimeoutMs)
MessageListener.onMessage(Message) can take to process a message.
Non-positive values are rejected.onMessageTimeoutMs - - duration in millisecondspublic int getChannelsQos()
Channel.basicQos(int)public void setChannelsQos(int channelsQos)
channelsQos - maximum number of messages that the server
will deliver, 0 if unlimitedChannel.basicQos(int)public void setPreferProducerMessageProperty(boolean preferProducerMessageProperty)
MessageProducer properties (delivery mode,
priority, TTL) take precedence over respective Message
properties or not.
Default is true (which is compliant to the JMS specification).public boolean isPreferProducerMessageProperty()
public void setRequeueOnMessageListenerException(boolean requeueOnMessageListenerException)
RuntimeException in the
MessageListener or not.
Default is false.setRequeueOnTimeout(boolean)public boolean isRequeueOnMessageListenerException()
public void setNackOnRollback(boolean nackOnRollback)
Default is false.
nackOnRollback - true to nack and discard messages on rollback, false to requeue thempublic boolean isNackOnRollback()
public void setCleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose(boolean cleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose)
public boolean isCleanUpServerNamedQueuesForNonDurableTopicsOnSessionClose()
public void setAmqpPropertiesCustomiser(java.util.function.BiFunction<com.rabbitmq.client.AMQP.BasicProperties.Builder,javax.jms.Message,com.rabbitmq.client.AMQP.BasicProperties.Builder> amqpPropertiesCustomiser)
public void setHostnameVerification(boolean hostnameVerification)
hostnameVerification - ConnectionFactory.enableHostnameVerification()public void setMetricsCollector(com.rabbitmq.client.MetricsCollector metricsCollector)
metricsCollector - ConnectionFactory.setMetricsCollector(MetricsCollector)public java.util.List<java.lang.String> getUris()
public void setAmqpConnectionFactoryPostProcessor(java.util.function.Consumer<com.rabbitmq.client.ConnectionFactory> amqpConnectionFactoryPostProcessor)
ConnectionFactory.
The post-processor is called before the AMQP connection creation. This callback can be
useful to customize the ConnectionFactory:
TLS-related configuration, metrics collection, etc.
amqpConnectionFactoryPostProcessor - public void setSendingContextConsumer(SendingContextConsumer sendingContextConsumer)
SendingContextConsumer,
SendingContextpublic void setReceivingContextConsumer(ReceivingContextConsumer receivingContextConsumer)
receivingContextConsumer - ReceivingContextConsumerpublic void setDeclareReplyToDestination(boolean declareReplyToDestination)
replyTo destination for consumed messages should be declared.
Default is true. Set this value to false for the
server-side of RPC, this avoids creating a temporary reply-to destination on
both client and server, leading to an error.
This is implemented as ReceivingContextConsumer.
setReceivingContextConsumer(ReceivingContextConsumer)@Deprecated public void setConfirmListener(ConfirmListener confirmListener)
MessageProducer send methods with a CompletionListener
When this property is set, publisher confirms are enabled for all
the underlying AMQP Channels created by
this ConnectionFactory.
This API is deprecated since the library supports JMS 2.0 Asynchronous Send
(CompletionListener API). It will be removed in RabbitMQ JMS Client 3.0.
Do not use async send methods and the ConfirmListener API
at the same time, the behavior when they are both in use is not determined.
confirmListener - the callbackConfirmListener,
MessageProducer.send(Message, CompletionListener),
MessageProducer.send(Destination, Message, CompletionListener),
MessageProducer.send(Message, int, int, long, CompletionListener),
MessageProducer.send(Destination, Message, int, int, long, CompletionListener)public void setRequeueOnTimeout(boolean requeueOnTimeout)
setRequeueOnMessageListenerException(boolean)public void setKeepTextMessageType(boolean keepTextMessageType)
public void setValidateSubscriptionNames(boolean validateSubscriptionNames)
public javax.jms.JMSContext createContext()
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(java.lang.String username,
java.lang.String password)
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(java.lang.String username,
java.lang.String password,
int sessionMode)
createContext in interface javax.jms.ConnectionFactorypublic javax.jms.JMSContext createContext(int sessionMode)
createContext in interface javax.jms.ConnectionFactoryCopyright © 2022. All rights reserved.