0

I have a jms connection settings that is defined in jndi.properties file on my classpath which I used to connect to ActiveMQ in my local development environment. I would like to rename this file to "activemq.jndi.properties" as I am planning to have another jms connection settings to WebsphereMQ ( say webshperemq.jndi.properties ). However I have no success so far in telling spring in my applicationContext.xml to look at activemq.jndi.properties.

Here is a snippet of my applicationContext.xml which works for jndi.properties

<!-- Define how to connect to the Message Queueing system -->
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"    value="${jms.connectionFactory}" />
    <property name="resourceRef" value="true" />  
</bean>

<bean id="defaultDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName"    value="${jms.topic}" />
    <property name="resourceRef" value="true" />
</bean>

<!-- Define a connection template that links to the factory -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory" />
    <property name="defaultDestination" ref="defaultDestination" />
    <property name="receiveTimeout" value="6000" />
</bean>

Both ${jms.connectionFactory} and ${jms.topic} are being filtered from maven. Any input on what needs to be changed in my applicationContext.xml to make it load from activemq.jndi.properties would be much appreciated.

Thanks!

1 Answers1

0

Well, Ithink you should configure maven resources so use one of another configuration file depending of the profile instead change anything in your Spring configuration file.

For example:

<profiles>
    <profile>
        <id>local</id>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                    <includes>
                        <include>jndi.properties</exclude>
                    </excludes>
                </resource>
            </resources>
        </build>
    </profile>
    <profile>
        <id>webshpere</id>
        <build>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>true</filtering>
                    <includes>
                        <include>webshperemq.jndi.properties</exclude>
                    </excludes>
                </resource>
            </resources>
        </build>
    </profile>
</profiles>
jddsantaella
  • 3,657
  • 1
  • 23
  • 39
  • Hi jddsantaella, thanks for your input, however element is not valid inside element in maven, so your suggestion above would not have worked. Basically if I rename jndi.properties to activemq.jndi.properties how do I tell spring (if at all possible) to "look" at activemq.jndi.properties rather than jndi.properties (which is the default that Spring will load)? – Lenny Halim May 30 '12 at 03:38
  • Resource definitions are valid inside profiles. I have updated my answer to show you the whole structure – jddsantaella May 30 '12 at 06:12