开发者

Connect to EMS JMS queue using Spring3 + JNDI

开发者 https://www.devze.com 2023-03-21 13:27 出处:网络
I\'m having some issues create a connection to (and reading from) a Tibco EMS JMS queue. <beans>

I'm having some issues create a connection to (and reading from) a Tibco EMS JMS queue.

<beans>
    <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">tcp://ems-dit-am-uat-1.app.xxx.net:30055</prop>
            </props>
        </property>
    </bean>

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

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

    <bean id="destination" class="org.sp开发者_如何学运维ringframework.jndi.JndiObjectFactoryBean">
        <property name="jndiTemplate" ref="jndiTemplate" />
        <property name="jndiName" value="Q.NY.DERIV.DRD.RFI" />
    </bean>

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


    <bean id="jmsReceiver" class="com.csfb.fao.rds.rfi.application.DRDReceiverTst">
        <property name="jmsTemplate">
            <ref bean="jmsTemplate" />
        </property>
    </bean>

</beans>

The exception I'm getting is:

javax.naming.AuthenticationException: Not permitted: invalid name or password [Root exception is javax.jms.JMSSecurityException: invalid name or password] at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:668) at com.tibco.tibjms.naming.TibjmsContext.lookup(TibjmsContext.java:489) at javax.naming.InitialContext.lookup(InitialContext.java:392) at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:154) at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:87) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152) at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178) at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95) at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105) at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201) at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417) ... 12 more

The only user/password I've been given is for the JMS queue itself - where do I set that?

Thanks Chris


Got it - needed to wrap the connection factory in a UserCredentialsConnectionFactory:

<bean id="authenticationConnectionFactory"
    class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="jmsConnectionFactory" />
    <property name="username" value="yyyyy" />
    <property name="password" value="xxxx" />
</bean>

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


I had some similar problem , solution was to add (besides solution from this question)

<prop key="java.naming.security.principal">username</prop>
<prop key="java.naming.security.credentials">password</prop>

to jndiTemplate bean configuration


I don't have any experience with EMS, but user and password are typically set on the connection factory, so you'd want to configure that on the object being provided by JNDI.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号