我将 Spring 配置的 jms 模板与 tibco jms 库一起使用。我使用 JNDI 获得 jms 连接工厂和主题,并且这些对象不为空。但是当我尝试发送消息或添加监听器时,我得到了这个异常:
对于听众:
Exception in thread "main" org.springframework.jms.InvalidDestinationException: Can not send into foreign destinations; nested exception is javax.jms.InvalidDestinationException: Can not send into foreign destinations
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:277)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
at org.springframework.jms.core.JmsTemplate.receiveSelected(JmsTemplate.java:700)
at org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:682)
at org.springframework.jms.core.JmsTemplate.receive(JmsTemplate.java:674)
对于发件人:
Exception in thread "main" org.springframework.jms.InvalidDestinationException: Invalid or foreigndestination; nested exception is javax.jms.InvalidDestinationException: Invalid or foreigndestination
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:277)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:539)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:531)
客户端应用程序正在使用相同的主题而没有问题(因此 jms 服务器正在运行)。你有什么想法?我在 javadoc 中读到了这个异常,但找不到如何理解根本问题并修复它。谢谢
UPD:配置中与 JMS 相关的部分:
<bean id="JmsFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jms.factory}"/>
<property name="proxyInterface" value="javax.jms.TopicConnectionFactory" />
<property name="lookupOnStartup" value="false" />
<property name="jndiEnvironment">
<props>
<prop key="java.naming.provider.url">${jms.namingProvider}</prop>
<prop key="java.naming.factory.initial">${jms.namingFactory}</prop>
<prop key="java.naming.referral">${jms.namingReferral}</prop>
<prop key="java.naming.security.credentials">${jms.securityCredentials}</prop>
<prop key="java.naming.security.principal">${jms.securityPrincipal}</prop>
</props>
</property>
</bean>
<bean id="JmsTopic" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="${jms.topic}"/>
<property name="proxyInterface" value="javax.jms.Topic" />
<property name="lookupOnStartup" value="false" />
<property name="jndiEnvironment">
<props>
<prop key="java.naming.provider.url">${jms.namingProvider}</prop>
<prop key="java.naming.factory.initial">${jms.namingFactory}</prop>
<prop key="java.naming.referral">${jms.namingReferral}</prop>
<prop key="java.naming.security.credentials">${jms.securityCredentials}</prop>
<prop key="java.naming.security.principal">${jms.securityPrincipal}</prop>
</props>
</property>
</bean>
<bean id="UserCredentialsConnectionFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory">
<ref bean="JmsFactory" />
</property>
<property name="username" value="${jms.user}" />
<property name="password" value="${jms.password}" />
</bean>
<bean id="JmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory"
ref="UserCredentialsConnectionFactory" />
<property name="defaultDestination">
<ref bean="JmsTopic"/>
</property>
<property name="pubSubDomain" value="true" />
</bean>