1

Referring to this post we have JMS configuration for webapp that can work for ActiveMQ but we are using OSB instead of ActiveMQ. What should be the modified configuration so that ConnectionFactory can work for OSB. I not able to create a substitute replacement for below connectionFactory configuration section that can work for OSB.

<bean id="connectionFactory" 
  class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="${jms.brokerUrl}"/>
    <property name="userName" value="${jms.userName}"/>
    <property name="password" value="${jms.password}"/>
    <property name="exceptionListener" ref="jmsExceptionListener"/>
    <property name="transportListener" ref="jmsTransportListener"/>
</bean>
2

You probably can use Spring's JMS listener combined with OSB. Configuration looks this this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

    <bean id="cacheMessageListener" class="org.dd4t.core.caching.jms.impl.JMSCacheMessageListener"/>

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                <prop key="java.naming.provider.url">${jms.brokerUrl}</prop>
            </props>
        </property>
    </bean>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>jms/connectionFactory</value>
        </property>
    </bean>

    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="cache">
            <value>true</value>
        </property>
    </bean>

    <bean id="tridionJmsCachingQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
            <ref bean="queueConnectionFactory" />
        </property>
        <property name="destinationResolver">
            <ref bean="jmsDestinationResolver" />
        </property>
    </bean>

    <bean id="tridionJmsQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>j${jms.topicName}</value>
        </property>
    </bean>
    <bean id="jmsListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="concurrentConsumers" value="5" />
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="destination" ref="tridionJmsQueue" />
        <property name="messageListener" ref="cacheMessageListener" />
    </bean>
</beans>
  • Thanks Raimond for solving this puzzle, one question the bean <tridionJmsCachingQueueTemplate> seems not used anywhere do we need this ? – Gulshan Thakur Jun 7 '17 at 19:55
  • Wasn't sure whether it was needed. If it can be removed, then great. – Raimond Jun 8 '17 at 8:03
1

Configuration mentioned by Raimond above works and the spring webapp is now able to make connection to the JMS topic defined in OSB. Just couple of minor corrections thats why pasting the conf again here:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

    <bean id="cacheMessageListener" class="org.dd4t.core.caching.jms.impl.JMSCacheMessageListener"/>

    <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
            <props>
                <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
                <prop key="java.naming.provider.url">${jms.brokerUrl}</prop>
            </props>
        </property>
    </bean>

    <bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>jms/connectionFactory</value> //JNDI name defined for the connection factory created in JMS
        </property>
    </bean>

    <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="cache">
            <value>true</value>
        </property>
    </bean>

    <bean id="tridionJmsCachingQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory">
            <ref bean="connectionFactory" />
        </property>
        <property name="destinationResolver">
            <ref bean="jmsDestinationResolver" />
        </property>
    </bean>

    <bean id="tridionJmsQueue" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate">
            <ref bean="jndiTemplate" />
        </property>
        <property name="jndiName">
            <value>${jms.topicName}</value>
        </property>
    </bean>
    <bean id="jmsListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="concurrentConsumers" value="5" />
        <property name="connectionFactory" ref="connectionFactory" />
        <property name="destination" ref="tridionJmsQueue" />
        <property name="messageListener" ref="cacheMessageListener" />
    </bean>
</beans>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.