JT400 - MSGW Response

Can I answer the MSGW job in the AS400 from the JT400?
I have a Job element and I can find out if it is in MSGW status with Job.MESSAGE_REPLY_WAITING

Ex: I usually use "C" through WRKACTJOB

+4
source share
3 answers

This is the code that works. I think it can be reduced and optimized.
There must be a better way!

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;
}

If you do not know the message queue, you can use an ObjectList.

0
source

David is right ... but there aren’t enough a couple of steps, I think .. and mind you, I haven’t tried either ...

Get the job:
Job.getJobLog()

Receive Queued Messages
JobLog.getMessages

Get message queue
QueuedMessage.getQueue()

MessageQueue.reply()

+4

, reply MessageQueue (JTOpen).

+2
source

Source: https://habr.com/ru/post/1652199/


All Articles