In a comment to my previous post about configuring JMS via Spring, Vikas Kadam asked about configuring a connection to a secure TIBCO EMS topic or queue. As fate would have it, the next issue I dealt with was adding this to my own application. What worked for me was using Spring’s UserCredentialsConnectionFactoryAdapter as my connection factory for my JmsTemplate. The final configuration looked like this:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="file:${catalina.home}/conf/jms.properties" /> </bean> <bean id="messageSender" class="com.stevideter.spring.jms.MessageSender"> <property name="jmsTemplate" ref="jmsTemplate" /> </bean> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="userCredentialsConnectionFactory" /> <property name="defaultDestinationName" value="${jms.defaultdestinationname}" /> <property name="pubSubDomain" value="${jms.istopic}" /> </bean> <bean id="userCredentialsConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter"> <property name="targetConnectionFactory"> <ref bean="topicConnectionFactory" /> </property> <property name="username" value="${jms.username}" /> <property name="password" value="${jms.password}" /> </bean> <bean id="topicConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate" ref="jndiTemplate" /> <property name="jndiName" value="${jms.connectionfactory}" /> </bean> <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial"> com.tibco.tibjms.naming.TibjmsInitialContextFactory </prop> <prop key="java.naming.provider.url"> ${jms.jndicontexturl} </prop> </props> </property> </bean> </beans> |