gpt4 book ai didi

java 。如何通过远程 channel 连接到远程Websphere MQ?

转载 作者:行者123 更新时间:2023-12-02 04:33:33 25 4
gpt4 key购买 nike

有一个系统 (IBM MDM) channel :SC.MDM.QM在此 channel 上,您可以联系公交车的管理员。例如:M99.ESB.MDM2,其中包含消息队列:ESB.IBSO.TB49.MDM.ORG.IN

这就是我们如何将消息放入队列(使用 RFHUtil 实用程序):

队列管理器名称(要连接的)

SC.MDM.QM/TCP/megri-t5.cgs.sbrf.ru(1414)

队列名称

ESB.IBSO.TB49.MDM.ORG.IN

远程队列管理器名称(仅限远程队列)

M99.ESB.MDM2

但是当我尝试通过 java 类设置相同的设置时:

public class SetWebsphere extends ConnectSettings {

public static String queueName = "ESB.IBSO.TB49.MDM.ORG.IN";

MQQueue defaultLocalQueue;
MQQueueManager qManager;

@SuppressWarnings({ "unchecked", "deprecation" })
public void init(){
//Set MQ connection credentials to MQ Envorinment.
MQEnvironment.hostname = hostName;
MQEnvironment.channel = channel;
MQEnvironment.port = port;
MQEnvironment.userID = user;

MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);

try {
//initialize MQ manager.
qManager = new MQQueueManager(qMngrStr);
} catch (MQException e) {
e.printStackTrace();
}
}

@SuppressWarnings("deprecation")
public void putAndGetMessage(String msg){
int openOptions = MQC.MQOO_OUTPUT | MQC.MQOO_INQUIRE;
try {
defaultLocalQueue = qManager.accessQueue(queueName, openOptions);
System.out.println(queueName);

MQMessage putMessage = new MQMessage();

byte[] xk = msg.getBytes("UTF-8");
putMessage.write(xk);
putMessage.characterSet = 1208;
//specify the message options...
MQPutMessageOptions pmo = new MQPutMessageOptions();
// accept
// put the message on the queue
defaultLocalQueue.put(putMessage, pmo);

System.out.println("Message is put on MQ.");

defaultLocalQueue.close();
qManager.disconnect();
} catch (MQException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

public class ConnectSettings {

static String qMngrStr;
static String hostName;
static String channel;
static int port;

public static void ConnectIFT() {

qMngrStr = "M99.ESB.MDM2";
hostName = "megri-t5.cgs.sbrf.ru";
port = 1414;
channel = "SC.MDM.QM";
}
}

结果是:

com.ibm.mq.MQException: MQJE001: Completion code '2', Reason'2058'.
at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:238)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11._createManagedConnection(MQClientManagedConnectionFactoryJ11.java:505)
at com.ibm.mq.MQClientManagedConnectionFactoryJ11.createManagedConnection(MQClientManagedConnectionFactoryJ11.java:547)
at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:95)
at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:182)
at com.ibm.mq.MQQueueManagerFactory.obtainBaseMQQueueManager(MQQueueManagerFactory.java:869)
at com.ibm.mq.MQQueueManagerFactory.procure(MQQueueManagerFactory.java:761)
at com.ibm.mq.MQQueueManagerFactory.constructQueueManager(MQQueueManagerFactory.java:712)
at com.ibm.mq.MQQueueManagerFactory.createQueueManager(MQQueueManagerFactory.java:171)
at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:603)
at ibmWebsphereMQ.SetWebsphere.init(SetWebsphere.java:67)
at ibsoTestWebsphereMQ.IBSOTest.IBSOCreateCLient(IBSOTest.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:768)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1188)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1113)
at org.testng.TestNG.run(TestNG.java:1025)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)

例如,如果我尝试通过总线 channel 进行连接,则此代码可以正常工作(另一台服务器):

qMngrStr = "M99.ESB.MDM2";
hostName = "iskona-t2.cgs.sbrf.ru";
port = 1422;
channel = "SC.M99.ESB.MDM2";

主要问题:如何使用java代码通过系统 channel (SC.MDM.QM)将消息放入队列?

提前致谢!

最佳答案

原因代码 2058 指向队列管理器名称错误。您确定在代码中提供了正确的队列管理器名称吗?您可能提供了正确的 channel 、主机、端口和传输类型,但队列管理器名称不正确。因此请检查队列管理器是否正确。

关于 java 。如何通过远程 channel 连接到远程Websphere MQ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31132554/

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