在AS400中可以从JT400回复MSGW作业吗?
我得到了作业元素,我可以通过Job.MESSAGE_REPLY_WAITING知道它是否处于MSGW状态
例:通常我通过WRKACTJOB使用"C“
发布于 2016-08-24 21:19:15
这是起作用的代码。我认为它可以缩短和优化。
一定有更好的办法!
public boolean answer(String answer) throws MyOperationException {
if (answer == null || answer.length() > 1) {
throw new MyOperationException();
}
MessageQueue msgq = new MessageQueue(as.getAS400(), QSYSObjectPathName.toPath(MyAS400.LIBRARY_LIST, "QSYSOPR", "MSGQ"));
msgq.setSelectMessagesNeedReply(true);
msgq.setListDirection(false);
try {
Enumeration m = msgq.getMessages();
while (m.hasMoreElements()) {
QueuedMessage msg = (QueuedMessage) m.nextElement();
if (msg.getFromJobNumber().trim().equals(getNumber())) {
msgq.reply(msg.getKey(), answer);
return true;
}
}
} catch (AS400SecurityException | ErrorCompletingRequestException | InterruptedException | IOException | ObjectDoesNotExistException ex) {
ex.printStackTrace();
}
return false;
}如果您不知道消息队列,可以使用ObjectList。
发布于 2016-08-23 17:20:43
大卫的correct...but错过了几步我think..and注意到我也没试过。
拿到工作日志:
Job.getJobLog()
获取排队的消息
JobLog.getMessages
获取消息队列
QueuedMessage.getQueue()
然后回复
MessageQueue.reply()
发布于 2016-08-23 15:54:55
实际上,我还没有尝试过这一点,但是请看一下reply函数在MessageQueue (JTOpen)中的应用。
https://stackoverflow.com/questions/39103382
复制相似问题