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.