JMS 错误:无法发送到国外目的地

发布于 2024-09-02 09:01:15 字数 4369 浏览 1 评论 0原文

我将 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>

I use Spring-configured jms template with tibco jms library.
I get jms connection factory and topic with JNDI and these objects are not null. But when I try to send message or add listener I get this exception:

For listener:

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)

For sender:

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)

Client app is working with the same topic without problems (so jms server is running). Do you have any ideas? I read about this exception in javadoc, but can't find how to understand the root issue and fix it.
Thanks

UPD:
JMS-related part of config:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月下伊人醉 2024-09-09 09:01:15

听起来您已将其配置为尝试创建目标,而不是执行 jndi 查找来获取已在 EMS 实例上定义的目标。

不过,您需要发布您的 spring 配置来确定。

编辑:如果您在 JmsTemplate 上设置目的地名称并为其提供 JndiDestinationResolver 那么它应该可以工作

It sounds like you have it configured so that it is attempting to create a destination rather than do a jndi lookup to get the destination that has been defined on the EMS instance.

You need to post your spring config to be sure though.

edit: if you set a destinationname on the JmsTemplate and provide it with a JndiDestinationResolver then it should work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文