public class RMQObjectFactory
extends java.lang.Object
implements javax.naming.spi.ObjectFactory
An example Tomcat configuration for a ConnectionFactory would look like:
<Resource name="jms/ConnectionFactory" type="javax.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="javax.jms.ConnectionFactory"
factory="com.rabbitmq.jms.admin.RMQObjectFactory"
uri="amqp://guest:guest@127.0.0.1"
the type attribute can be ConnectionFactory, QueueConnectionFactory,
TopicConnectionFactory or the actual classname of the implementation,
RMQConnectionFactory.
A destination, Queue or Topic, can be created using the following configuration (Queue first):
<Resource name="jms/Queue" type="javax.jms.Queue"
factory="com.rabbitmq.jms.admin.RMQObjectFactory"
destinationName="queueName"/>
and a Topic would be created thus:
<Resource name="jms/Topic" type="javax.jms.Topic"
factory="com.rabbitmq.jms.admin.RMQObjectFactory"
destinationName="topicName"/>
An example Wildfly configuration for a ConnectionFactory would 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="javax.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:
javax.jms.ConnectionFactory javax.jms.QueueConnectionFactory javax.jms.TopicConnectionFactory javax.jms.Topic javax.jms.Queue
Valid properties for a ConnectionFactory are:
uri attribute, the default value is the same as that obtained by instantiating a
RMQConnectionFactory object with the default constructor.
Properties for a Topic or a Queue are:
| Constructor and Description |
|---|
RMQObjectFactory() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
createConnectionFactory(javax.naming.Reference ref,
java.util.Hashtable<?,?> environment,
javax.naming.Name name)
Creates a RMQConnectionFactory from a Reference or environment Hashtable
|
java.lang.Object |
createDestination(javax.naming.Reference ref,
java.util.Hashtable<?,?> environment,
javax.naming.Name name,
boolean topic)
Create a
RMQDestination from a Reference of environment Hashtable |
java.lang.Object |
getObjectInstance(java.lang.Object obj,
javax.naming.Name name,
javax.naming.Context ctx,
java.util.Hashtable<?,?> environment) |
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
getObjectInstance in interface javax.naming.spi.ObjectFactoryjava.lang.Exceptionpublic java.lang.Object createConnectionFactory(javax.naming.Reference ref,
java.util.Hashtable<?,?> environment,
javax.naming.Name name)
throws javax.naming.NamingException
ref - the reference containing propertiesenvironment - the environment containing propertiesname - the name of the objectRMQConnectionFactory object configuredjavax.naming.NamingException - if a required property is missing or invalidpublic java.lang.Object createDestination(javax.naming.Reference ref,
java.util.Hashtable<?,?> environment,
javax.naming.Name name,
boolean topic)
throws javax.naming.NamingException
RMQDestination from a Reference of environment Hashtableref - 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)RMQDestination object with the destinationName configuredjavax.naming.NamingException - if the destinationName property is missingCopyright © 2023. All rights reserved.