4

是否可以从 JT400 回复 AS400 中的 MSGW 作业?
我有 Job 元素,我可以通过 Job.MESSAGE_REPLY_WAITING 知道它是否处于 MSGW 状态

例如:通常我通过 WRKACTJOB 使用“C”

4

3 回答 3

4

大卫是正确的......但我认为错过了几个步骤......请注意我也没有尝试过这个......

获取工作日志:
Job.getJobLog()

获取排队的消息
JobLog.getMessages

获取消息队列
QueuedMessage.getQueue()

然后回复
MessageQueue.reply()

于 2016-08-23T17:20:43.207 回答
2

我实际上并没有尝试过,但请看一下MessageQueue ( JTOpen )中的reply函数。

于 2016-08-23T15:54:55.070 回答
0

这是有效的代码。我认为它可以缩短和优化。
一定会有更好的办法!

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-24T21:19:15.477 回答