gpt4 book ai didi

java - 无法使用 JNDI 连接到 Websphere MQ

转载 作者:行者123 更新时间:2023-12-01 13:42:24 29 4
gpt4 key购买 nike

StackOverflow 社区大家好,

我目前正在使用 Spring 连接到队列。我希望能够在我们的测试 VS 我们的 UAT 环境中配置我可以连接的提供商。在UAT中,我们使用IBM WMQ 7;在测试中,我们使用 ActiveMQ。

在这两种情况下,我们都使用 SSL 连接。

目前,我们有以下配置可用于连接到 WMQ 7:

<bean id="jmsFactory" name="jmsFactory" class="com.ibm.mq.jms.MQConnectionFactory">
<property name="queueManager" value="${UM_MQ_QM}" />
<property name="hostName" value="${UM_MQ_HOST}" />
<property name="channel" value="${UM_MQ_CHANNEL}" />
<property name="port" value="${UM_MQ_PORT}" />
<property name="transportType" value="1" />
<property name="SSLCipherSuite" value="${SSL_CIPHER_SUITE}" />
</bean>

使用 JNDI,我能够连接到 ActiveMQ。但是当切换提供程序类时,它给了我以下异常。

Spring JNDI 配置:

<bean id="jmsFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="QueueConnectionFactory" />
<property name="jndiTemplate" ref="jndiTemplate" />
</bean>

<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.ibm.mq.jms.context.WMQInitialContextFactory</prop>
<prop key="java.naming.provider.url">${UM_MQ_HOST}:${UM_MQ_PORT}/${UM_MQ_CHANNEL}</prop>
</props>
</property>
</bean>

异常(exception):

Caused by: javax.naming.NamingException: Caught an Exception trying to create the admin queue. Exception was: com.ibm.mq.pcf.PCFException: MQJE001: Completion Code '2', Reason '2035'. [Root exception is com.ibm.mq.pcf.PCFException: MQJE001: Completion Code '2', Reason '2035'.]
at com.ibm.mq.jms.context.MQContext.<init>(MQContext.java:294)
at com.ibm.mq.jms.context.WMQInitialContextFactory.getInitialContext(WMQInitialContextFactory.java:29)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:136)
at org.springframework.jndi.JndiTemplate.getContext(JndiTemplate.java:103)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
at org.springframework.jndi.JndiObjectFactoryBean.lookupWithFallback(JndiObjectFactoryBean.java:201)
at org.springframework.jndi.JndiObjectFactoryBean.afterPropertiesSet(JndiObjectFactoryBean.java:187)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 109 more
Caused by: com.ibm.mq.pcf.PCFException: MQJE001: Completion Code '2', Reason '2035'.
at com.ibm.mq.pcf.PCFMessageAgent.send(PCFMessageAgent.java:241)
at com.ibm.mq.jms.context.MQContext.<init>(MQContext.java:273)
... 125 more

我怀疑这是由于以下两件事造成的:

  1. 我们没有对上述 JMS 管理队列设置显式权限
  2. 密码设置在 Spring 配置中不起作用

谁能提供一些指导吗?如果您以前遇到过这个问题,解决方案是什么?

我确信答案就在我面前,只是我的眼睛里有些雾气:)

谢谢

何塞

最佳答案

您不想使用 WMQInitialContextFactory。使用基于文件的 JNDI 或真正的 JNDI 注册表。

WMQInitialContextFactory 来自 SupportPac ME01,由 IBM 员工编写,作为一个简单的开发工具,仅用于开发 - 永远不会用于生产。除了简单开发之外,不建议使用 SupportPac ME01。大多数 IBM MQ 人们都说永远不要使用它。此外,IBM 不支持 WMQInitialContextFactory。

曾经告诉您使用 WMQInitialContextFactory 的人需要重新了解 IBM MQ 最佳实践。

关于java - 无法使用 JNDI 连接到 Websphere MQ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20615721/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com