您能帮助我吗?我正在尝试通过 SSL channel 使用 PCFAgent 查找 ibm mq 深度。
Security.setProperty("ssl.SocketFactory.provider", "com.ibm.jsse2.SSLSocketFactoryImpl");
Security.setProperty("ssl.ServerSocketFactory.provider", "com.ibm.jsse2.SSLServerSocketFactoryImpl");
System.setProperty("javax.net.ssl.trustStore","abc-dev.jks");
System.setProperty("javax.net.ssl.trustStorePassword","abcdabcd");
System.setProperty("javax.net.ssl.keyStore", "abc-dev.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "abcdabcd");
MQEnvironment.sslCipherSuite = "TLS_RSA_WITH_AES_128_CBC_SHA";
int attrs[] = { 2016, 3 };
System.out.println("parameter creation");
PCFParameter parameters[] = { new MQCFST(2016, "*"), new MQCFIN(20, 1),
new MQCFIL(1002, attrs) };
String name = null;
Integer depth = null;
System.out.println("parameter creation end");
try {
PCFAgent agent;
if (args.length == 1) {
System.out.print("Connecting to local queue manager " + args[0]
+ "... ");
agent = new PCFAgent(args[0]);
} else {
System.out.print("Connecting to queue manager at " + args[0]
+ ":" + args[1] + " over channel " + args[2] + "... ");
agent = new PCFAgent(args[0], Integer.parseInt(args[1]),
args[2]);
}
System.out.println("Connected.");
System.out.print("Sending PCF request... ");
com.ibm.mq.MQMessage responses[] = agent.send(13, parameters);
System.out.println("Received reply.");
for (int i = 0; i < responses.length; i++) {
MQCFH cfh = new MQCFH(responses[i]);
if (cfh.reason == 0) {
for (int j = 0; j < cfh.parameterCount; j++) {
PCFParameter p = PCFParameter
.nextParameter(responses[i]);
switch (p.getParameter()) {
case 2016:
name = (String) p.getValue();
break;
case 3: // '\003'
depth = (Integer) p.getValue();
break;
}
}
System.out.println("Queue " + name + " curdepth " + depth);
} else {
System.out.println("PCF error:\n" + cfh);
for (int j = 0; j < cfh.parameterCount; j++)
System.out.println(PCFParameter
.nextParameter(responses[0]));
}
}
System.out.print("Disconnecting... ");
agent.disconnect();
System.out.println("Done.");
} catch (ArrayIndexOutOfBoundsException abe) {
System.out
.println("Usage: \n\tjava ListQueueDepth queue-manager\n\tjava ListQueueDepth host port channel");
} catch (NumberFormatException nfe) {
System.out.println("Invalid port: " + args[1]);
System.out
.println("Usage: \n\tjava ListQueueDepth queue-manager\n\tjava ListQueueDepth host port channel");
} catch (MQException mqe) {
System.err.println(mqe);
} catch (IOException ioe) {
System.err.println(ioe);
}
当我尝试远程运行该程序时,出现以下异常:
com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2035
编辑以添加评论中的其他澄清细节:
在应用程序收到 2035 的同时,MQ 管理员在与 SYSTEM.DEFAULT.MODEL.QUEUE 相关的 AMQERR01.LOG
中发现了错误。
当我取消安全设置和密码套件时,相同的程序适用于非 SSL channel 。
最佳答案
嗯,我没有看到你在代码中设置 UserID 的位置。因此,您发送的是一个空白的 UserID,如果 channel 的 MCAUSER 为空,则意味着由于旧的安全漏洞,它会变成“mqm”UserID。
对于 MQ v7.1 或更高版本,如果您位于“SYSTEM” channel ,则默认 CHLAUTH 规则将阻止连接。或者对于 MQ v8.0 或更高版本, channel 可能需要用户 ID 和密码。您需要查看事件队列或队列管理器日志以了解 RC 2035(未授权)的原因。
int attrs[] = { 2016, 3 };
PCFParameter parameters[] = { new MQCFST(2016, "*"),
new MQCFIN(20, 1),
new MQCFIL(1002, attrs) };
另外,硬编码值是怎么回事?你反编译过别人的程序吗?
为什么不使用 IBM MQ 提供的定义?它应该是这样的:
int[] attrs = {
CMQC.MQCA_Q_NAME,
CMQC.MQIA_CURRENT_Q_DEPTH
};
PCFParameter[] parameters = {
new MQCFST (CMQC.MQCA_Q_NAME, "*"),
new MQCFIN (CMQC.MQIA_Q_TYPE, CMQC.MQQT_LOCAL),
new MQCFIL (CMQCFC.MQIACF_Q_ATTRS, attrs)
};
关于java - IBM MQ 的深度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41669669/