2

I would like to get messages in AS400 from a queue other than a queue from QSYS.LIB. I am using the following code that runs well, only if I use a queue from within QSYS.LIB:

public String getMessagesFromQsysopr(boolean needReply) {


    String messageStr = "";
    try {

    MessageQueue queue = new MessageQueue(this.as400, "/qsys.lib/qsysopr.msgq");
 // want only inquiry messages
    queue.setSelectMessagesNeedReply(needReply);
    queue.setSelectMessagesNoNeedReply(!needReply);
    queue.setSelectSendersCopyMessagesNeedReply(needReply);
    queue.setListDirection(false);

    Enumeration e = queue.getMessages();
    while (e.hasMoreElements()) {
        QueuedMessage message = (QueuedMessage) e.nextElement();
        messageStr += message.getText()+"\n";
    }


} catch (Exception e) {
    e.printStackTrace();
}

If I replace the /qsys.lib/qsysopr.msgq for any other queue from other lib, like for example "/yaclib.lib/queueName.msgq" I get the following error:

com.ibm.as400.access.IllegalPathNameException: /yaclib.lib/queueName.msgq: Object not in QSYS file system. at com.ibm.as400.access.QSYSObjectPathName.parse(QSYSObjectPathName.java:599) at com.ibm.as400.access.QSYSObjectPathName.(QSYSObjectPathName.java:169) at com.ibm.as400.access.QSYSObjectPathName.(QSYSObjectPathName.java:177) at com.ibm.as400.access.MessageQueue.(MessageQueue.java:299) at br.com.operation.AS400Inspector.getMessagesFromYaclib(AS400Inspector.java:225) at br.com.operation.Main.main(Main.java:43)

Question 1: What am I doing wrong?

Question 2: Is there any way to limit the messages that don't need reply? Like get messages after a specific date or just the last 2 day messages?

Thanks.

  • 3
    `...for example "/yaclib.lib/queueName.msgq"` That's not a valid name. There is no _file system_ named **/yaclib.lib**. You want to reference library YACLIB. Using the IFS naming format, you'd start the path with the /qsys.lib file system so it becomes "/qsys.lib/yaclib.lib/queueName.msgq". – user2338816 Feb 09 '16 at 09:37
  • There is a method to QSYS'ify a given library+member in one of the IFS classes. Very handy to do this properly (there is a lot of rules to follow). – Thorbjørn Ravn Andersen Feb 14 '16 at 09:13

1 Answers1

3

@user2338816 is correct.

QSYS is a special library; it actually contains every other library in the system. From a 5250 session, WRKOBJ *ALL *LIB will confirm that every library is the system is in the QSYS library. Interestingly, QSYS itself is contained in QSYS.

When using IFS naming, to refer to a library of YACLIB.LIB, you need to use /QSYS.LIB/YACLIB.LIB

As far as selecting by date, no there's no way to do that. If you look at the java docs the closest you'll find is NEW, NEWEST, OLD, OLDEST

Charles
  • 21,637
  • 1
  • 20
  • 44
  • IFS naming is a work around to allow accessing libraries through a Unix-like file tree in addition to /usr and /tmp etc.. For the purpose of this question consider it a mount point for the AS/400 libraries. – Thorbjørn Ravn Andersen Feb 14 '16 at 09:03