【发布时间】:2019-03-09 07:23:37
【问题描述】:
当它作为 java 代码正常运行时,它工作得非常好,但是当它作为应用程序运行时,queueManager 显示为 NULL。所有这些代码都放在 onCreate(Bundle savedInstanceState) 中。当它作为 java 运行时,调试器实际上显示了一个 queueManager 值。
void init() {
int openOptions = CMQC.MQOO_INQUIRE | CMQC.MQOO_INPUT_AS_Q_DEF;
MQEnvironment.hostname = HOST;
MQEnvironment.channel = CHANNEL;
MQEnvironment.port = PORT;
MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
MQEnvironment.properties.put(CMQC.THREAD_AFFINITY_PROPERTY, new Boolean(true));
try {
queueManager = new MQQueueManager(QMGR);
System.out.println("Successfully connected to " + queueManager.getName());
defaultQueue = queueManager.accessQueue(QUEUE_NAME,openOptions);
System.out.println("Queue size: " + defaultQueue.getCurrentDepth());
} catch (MQException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
System.exit(2);
}
finally {
try {
if (queueManager != null);
queueManager.disconnect();
} catch (MQException e) {
e.printStackTrace();
}
try {
if (defaultQueue != null);
defaultQueue.close();
} catch (MQException e) {
e.printStackTrace();
}
}
}
【问题讨论】:
标签: ibm-mq