具有多个代理的JMSTemplate.目标解析异常 [英] JMSTemplate with multiple brokers. Destination resolving exception

查看:277
本文介绍了具有多个代理的JMSTemplate.目标解析异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一整天都在努力解决的问题,但是没有成功... 我有一个应用程序试图与外部系统A和外部系统B之间收发消息.A和B是基于WLS的外部系统.

I have problem which I am trying solve all day, without success... I have an application which trying to send/receive messages to/from external system A and external system B. A and B it is WLS based external systems.

我的应用程序即将发布时-我正在读取所有配置并构建我的应用程序JMSProducer,并在其中注入具有预定义目标名称的JMSTemlate.

While my application is coming up - i am reading all configurations and building my applicational JMSProducer and injecting JMSTemlate with predefined destination name in it.

这是我的代码:

private JMSProducer initProducer(Conf conf) {
    DestinationResolver destinationResolver = getDestinationResolver(conf);
    ConnectionFactory connectionFactory = getConnectionFactory();
    String destinationName = conf.getDestinationName();
    JmsTemplate jmsTemplate = new JmsTemplate();
    jmsTemplate.setConnectionFactory(connectionFactory);
    jmsTemplate.setDestinationResolver(destinationResolver);
    jmsTemplate.setDefaultDestinationName(destinationName);
    return new JMSProducer(jmsTemplate);
}

public DestinationResolver getDestinationResolver(Conf conf) {
    JndiDestinationResolver destinationResolver = new JndiDestinationResolver();
    destinationResolver.setCache(false);
    destinationResolver.setJndiTemplate(getJNDITemplate(conf));
    return destinationResolver;
}

private JndiTemplate getJNDITemplate(Conf conf) {
    JndiTemplate jndiTemplate = new JndiTemplate();
    Properties properties = new Properties();
    String connectionFactoryClassName = externalSystemConf.getConnectionParam().getConnectionFactory();
    properties.setProperty("java.naming.factory.initial", connectionFactoryClassName);
    properties.setProperty("java.naming.provider.url", getProviderURL(conf.getConnectionParam()));
    jndiTemplate.setEnvironment(properties);
    return jndiTemplate;
}

现在场景会发生什么.

Now scenario what happens.

我的应用程序已启动并正在运行,具有2个队列的外部系统A和具有1个队列的外部系统B也已启动并正在运行.

My app is up and running, external system A with 2 queues and external system B with 1 queue also is up and running.

  1. 我正在检索相关的,已经初始化的JMSProducer,在其中我已经向JMSTemplate注入了destinationName.
  2. 将消息发送到外部系统A的队列
  3. 再次检索与系统B相关的JMSProducer的下一个实例
  4. 将消息发送到外部系统B的队列
  5. 在此阶段,一切都很好,所有消息都传递到外部系统中的相关队列.
  6. 现在,我再次获得与外部系统A相关的JMSProducer,并尝试将消息发送到其中一个队列.在这个阶段,我遇到了一个问题,抛出了DestinationResolutionException:

在JNDI中找不到目标[topic2.queueName]

Destination [topic2.queueName] not found in JNDI

javax.naming.NameNotFoundException:尝试查找"topic2.queueName"时未找到子上下文"topic2".已解决"

javax.naming.NameNotFoundException: While trying to lookup 'topic2.queueName' didn't find subcontext 'topic2'. Resolved ""

这是有可能的,我刚刚将消息发送到了具有相同目的地的外部系统A,并且工作正常.为什么在尝试向B发送消息后向A发送消息时会抛出异常?

How it is possible, I have just sent messages to external system A with the same destination and it worked fine. Why it throwing exception when I am sending message to A after I tried to sent it to B?

顺便说一句,如果在定义目标解析器时尝试将缓存标志更改为true,则可以解决此问题.但是,在这种情况下,当我要重新启动外部系统时,我开始遇到问题.重新启动后,它也有一些与目标解析有关的异常.

By the way, If I will try to change cache flag to true when defining destination resolver, it is solving this problem. However in this case I starting to have problem when my external system is going to be restarted. After restart it also have some exception related to destination resolving.

推荐答案

已解决.

问题是在两个外部系统中,在WLS中,域名,jms服务器名称和jms模块名称都相同.并且weblogic客户端存储状态,并使用该名称进行映射.

Problem was that in both external systems, in WLS - domain name, jms server name, and jms module name were the same. And weblogic client stores state, map with this names.

这来自WLS文档

互操作的WebLogic Server域具有以下内容 限制:

Interoperating WebLogic Server domains have the following restrictions:

域名必须唯一.

WebLogic服务器名称必须唯一,即使它们是两个名称也是如此 不同的域.

WebLogic server names must be unique, even if they are in two different domains.

JMS服务器名称必须唯一,即使它们是两个不同的名称也是如此 域.

JMS server names must be unique, even if they are in two different domains.

互操作域可能有特殊的安全注意事项.

Interoperating domains may have special Security considerations.

https://docs.oracle.com /cd/E28280_01/web.1111/e13738/best_practice.htm#JMSAD635

更改所有上述名称后-问题已解决.

After changing all above mentioned names - problem was solved.

这篇关于具有多个代理的JMSTemplate.目标解析异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆