JMS MQ without JNDI

105 Views Asked by At

Due to some reason as we cannot use JNDI, can we use below code in spring application context ? Its working fine but need to know if any improvement/optimization is needed. Please note that almost 10 web applications will have this code and each will be creating its own connection factory.

<bean id="jmsTransactionManager"
        class="org.springframework.jms.connection.JmsTransactionManager">
        <property name="connectionFactory" ref="jmsConnectionFactory" />
    </bean>
          
    <bean id="mqQueueConnectionFactory" class="com.ibm.mq.jms.MQXAConnectionFactory">
        <property name="hostName" value="xxx" />
        <property name="port" value="xxx" />
        <property name="queueManager" value="xxx" />
        <property name="transportType" value="1" />
        <property name="channel" value="xxx" />
    </bean>
    
    <bean id="jmsConnectionFactory"
        class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="mqQueueConnectionFactory" />
        <property name="sessionCacheSize" value="20" />
    </bean>
    
    <bean id="queue" class="com.ibm.mq.jms.MQQueue">
        <constructor-arg value="xxx" />
            <property name="baseQueueManagerName">
            <value>xxx</value>
            </property>
            <property name="baseQueueName">
            <value>xxx</value>
            </property>
    </bean>
    
    <bean id="dynamicDestResolver" 
  class=" org.springframework.jms.support.destination.DynamicDestinationResolver"/>     
     
    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="jmsConnectionFactory" />
        <property name="destinationResolver" ref="jmsDestResolver" />
        <property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE" />
        <property name="sessionTransacted" value="true" /> 
    </bean>
0

There are 0 best solutions below