如何在spring为weblogic配置jms模板?

时间:2010-11-07 11:30:43

标签: spring weblogic jmstemplate

作为我的问题标题,如何在春季为weblogic配置jms模板?

我在一些网站上举了一个例子,但春天总是在JmsTemplate上抱怨defaultDestination

如何正确配置?

<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">t3://localhost:7001</prop>
        </props>
    </property>
</bean>

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

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

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

nb:我使用weblogic 9.2 for jms&amp; web server,spring 2.5.6

1 个答案:

答案 0 :(得分:5)

我发现,该目的地应包含jms目的地

<bean id="destination" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="jms/queue" />
</bean>

<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory" />
    <property name="destinationResolver" ref="jmsDestinationResolver" />
    <property name="defaultDestination" ref="destination" />
    <property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
    <property name="sessionTransacted" value="true" />
</bean>