I am running Tomcat which creates a DefaultMessageListenerContainer
bean. For that it refers to the connectionFactory
bean which uses the jndiTemplate
bean which uses a path at which the imq/imq_admin_objects
.
The bean definition is as follows
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="destination"/>
<property name="messageListener" ref="transactionMessageListener"/>
<property name="sessionTransacted" value="true"/>
<property name="concurrentConsumers" value="1"/>
</bean>
<!-- JMS configuration -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">
com.sun.jndi.fscontext.RefFSContextFactory
</prop>
<prop key="java.naming.provider.url">
file:///var/imq/imq_admin_objects
</prop>
</props>
</property>
</bean>
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate" ref="jndiTemplate"/>
<property name="jndiName" value="factory"/>
</bean>
The problem is that no such folder is generated. I am using the Message Queue Broker 4.5 for the JMS. On running the service it only creates a var/mq directory. I am expecting it to generate an imq folder which will have the respective bindings file which will be used to create the JMS.
I believe your expectation here is incorrect. The file-system object store referenced for com.sun.jndi.fscontext.RefFSContextFactory
must exist already. It doesn't create it for you. You have to create it and provide it so the bean can be initialized properly and the JNDI lookup can function.
The binding file contains details like the JNDI lookup names as well as how to connect to the server across the network (e.g. hostname, port, etc.). Those details must be provided by an administrator. The JNDI implementation can't come up with them on its own.
If you browse the "Developer’s Guide for Java Clients" linked from the Open MQ 4.5 Documentation page and inspect chapter 2 titled "Using the Java API" you'll see this in the "Obtaining a Connection Factory" section:
Typically, a connection factory is created for you by a Message Queue administrator and preconfigured, using the administration tools described in "Administrative Tasks and Tools" in Oracle GlassFish Server Message Queue Administration Guide with whatever property settings are appropriate for connecting to particular JMS provider. The factory is then placed in a publicly available administered object store, where you can access it by name using the Java Naming and Directory Interface (JNDI) API.
Further down in the document you'll find an example of how to look up a connection factory object in the JNDI object store. This examples uses the file-system object store just as you are and it specifically notes:
The directory represented by C:/imq_admin_objects must already exist; if necessary, you must create the directory before referencing it in your code.
In short, you must to create the administered file-system object store and make it publicly available so it can be used by JNDI clients.