JMS. Неправильно проанализированное имя очереди - PullRequest
1 голос
/ 06 мая 2020

Я пытаюсь создать MessageListener, но не могу подключиться к очереди. Я вижу, что имя очереди неправильно проанализировано.

Caused by: javax.naming.NameNotFoundException: While trying to lookup 'jms.queue.a-b-c.d/out' didn't find subcontext 'a-b-c'. Resolved 'jms.queue'

Конфигурация MY bean:

<bean id="messageListener-a-b-c"
    class="pl.sygnity.enea.sis.jms.SimpleMessageListener">
    <property name="initialContext" ref="sisInitialContext" />
    <property name="jndiName"
        value="weblogic/jms/XAConnectionFactory" />
    <property name="queueName"
        value="jms/queue/a-b-c/d/out" />
    <property name="isResponse" value="false" />
    <property name="messageId" value="test" />
</bean>

Я пытаюсь подключиться к очереди через:

@PostConstruct
public void init() {
    if (initialContext != null && initialContext.getInitialContext() != null) {
        try {
            InitialContext ic = initialContext.getInitialContext();
            if (connectionFactory == null) {
                connectionFactory = getConnectionFactory(ic);
            }
            if (connectionFactory != null) {
                QueueConnection queueConnection = (QueueConnection) connectionFactory.createConnection();
                setReconnectParams(queueConnection);
                QueueSession session = queueConnection.createQueueSession(false, Session.CLIENT_ACKNOWLEDGE);
                ((WLQueueSession) session).setRedeliveryDelay(redeliveryDelay);
                // Queue queue = (Queue) jndiTemplate.lookup(queueName);
                Queue queue = (Queue) ic.lookup(queueName);
                QueueReceiver qreceiver = session.createReceiver(queue);
                qreceiver.setMessageListener(this);
                queueConnection.start();

            } else {
            }
        } catch (JMSException | NamingException e) {
            logger.error("messageId: {}, queueName: {} : {}", messageId, queueName, e.getLocalizedMessage(), e);
        }
    } else {
    }
    noReDeliveryList = new ArrayList<String>();
}

EDIT

Реализация JNDI выглядит так, переменные среды в порядке, потому что я использую HermesJMS для тестирования очередей:

public class SisInitialContext {
    private static final Logger logger = LoggerFactory.getLogger(SisInitialContext.class);

    private JndiTemplate jndiTemplate;
    private InitialContext initialContext;
    private Properties environment;

    @PostConstruct
    public void init() {
        try {
            if (jndiTemplate != null) {
                initialContext = (InitialContext) jndiTemplate.getContext();
                // initialContext = new InitialContext(jndiTemplate.getEnvironment());
            } else {
                initialContext = new InitialContext(environment);
            }
        } catch (NamingException e) {
            logger.error("{}", e.getLocalizedMessage(), e);
        } catch (Exception e) {
            logger.error("{}", e.getLocalizedMessage(), e);
        }
    }
//getters, setters
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...