- java.lang.Object
-
- com.rabbitmq.jms.admin.RMQObjectFactory
-
- All Implemented Interfaces:
javax.naming.spi.ObjectFactory
public class RMQObjectFactory extends java.lang.Object implements javax.naming.spi.ObjectFactoryJNDI Factory to create resources in containers such as Tomcat.An example Tomcat configuration for a
ConnectionFactorywould look like:<Resource name="jms/ConnectionFactory" type="jakarta.jms.ConnectionFactory" factory="com.rabbitmq.jms.admin.RMQObjectFactory" username="guest" password="guest" virtualHost="/" host="localhost"/>Alternatively, a AMQP uri can be used:
<Resource name="jms/ConnectionFactory" type="jakarta.jms.ConnectionFactory" factory="com.rabbitmq.jms.admin.RMQObjectFactory" uri="amqp://guest:guest@127.0.0.1"the type attribute can be
ConnectionFactory,QueueConnectionFactory,TopicConnectionFactoryor the actual classname of the implementation,RMQConnectionFactory.A destination,
QueueorTopic, can be created using the following configuration (Queuefirst):<Resource name="jms/Queue" type="jakarta.jms.Queue" factory="com.rabbitmq.jms.admin.RMQObjectFactory" destinationName="queueName"/>and a
Topicwould be created thus:<Resource name="jms/Topic" type="jakarta.jms.Topic" factory="com.rabbitmq.jms.admin.RMQObjectFactory" destinationName="topicName"/>An example Wildfly configuration for a
ConnectionFactorywould look like:<object-factory name="java:global/jms/ConnectionFactory" module="org.jboss.genericjms.provider" class="com.rabbitmq.jms.admin.RMQObjectFactory"> <environment> <property name="className" value="jakarta.jms.ConnectionFactory"/> <property name="username" value="guest"/> <property name="password" value="guest"/> <property name="virtualHost" value="/"/> <property name="host" value="localhost"/> </environment> </object-factory>Valid types are:
jakarta.jms.ConnectionFactory jakarta.jms.QueueConnectionFactory jakarta.jms.TopicConnectionFactory jakarta.jms.Topic jakarta.jms.Queue
Valid properties for a
ConnectionFactoryare:- uri
- host
- password
- port
- queueBrowserReadMax
- onMessageTimeoutMs
- channelsQos
- ssl
- terminationTimeout
- username
- virtualHost
- className - only applies when properties are provided via environment HashTable
uriattribute, the default value is the same as that obtained by instantiating aRMQConnectionFactoryobject with the default constructor.Properties for a
Topicor aQueueare:- destinationName
-
-
Constructor Summary
Constructors Constructor Description RMQObjectFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ObjectcreateConnectionFactory(javax.naming.Reference ref, java.util.Hashtable<?,?> environment, javax.naming.Name name)Creates a RMQConnectionFactory from a Reference or environment Hashtablejava.lang.ObjectcreateDestination(javax.naming.Reference ref, java.util.Hashtable<?,?> environment, javax.naming.Name name, boolean topic)Create aRMQDestinationfrom a Reference of environment Hashtablejava.lang.ObjectgetObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context ctx, java.util.Hashtable<?,?> environment)
-
-
-
Method Detail
-
getObjectInstance
public java.lang.Object getObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context ctx, java.util.Hashtable<?,?> environment) throws java.lang.Exception- Specified by:
getObjectInstancein interfacejavax.naming.spi.ObjectFactory- Throws:
java.lang.Exception
-
createConnectionFactory
public java.lang.Object createConnectionFactory(javax.naming.Reference ref, java.util.Hashtable<?,?> environment, javax.naming.Name name) throws javax.naming.NamingExceptionCreates a RMQConnectionFactory from a Reference or environment Hashtable- Parameters:
ref- the reference containing propertiesenvironment- the environment containing propertiesname- the name of the object- Returns:
- a
RMQConnectionFactoryobject configured - Throws:
javax.naming.NamingException- if a required property is missing or invalid
-
createDestination
public java.lang.Object createDestination(javax.naming.Reference ref, java.util.Hashtable<?,?> environment, javax.naming.Name name, boolean topic) throws javax.naming.NamingExceptionCreate aRMQDestinationfrom a Reference of environment Hashtable- Parameters:
ref- the reference containing the propertiesenvironment- the environment containing the propertiesname- the nametopic- true if this is a topic, false if it is a queue (ignored if this is amqp-mapped)- Returns:
- a
RMQDestinationobject with the destinationName configured - Throws:
javax.naming.NamingException- if thedestinationNameproperty is missing
-
-