问题
- I'm trying to get queue message list. I already did it using this code. problem is i want to filter it to *inq. this code retrive all messages. but i want to get *inq messages only. how to do it ?
- I was used "/qsys.lib/qsysopr.msgq" to get QSYSOPR message queue messages. I want to get all message queue's messages. So whats the exact queue path to get all message queue's messages.
Thanks in Advance!
try {
AS400 system = new AS400();
MessageQueue queue = new MessageQueue(system, "/qsys.lib/qsysopr.msgq");
Enumeration e = queue.getMessages();
while (e.hasMoreElements()) {
QueuedMessage message = (QueuedMessage) e.nextElement();
System.out.println(message.getText());
}
System.out.println("End Messages!");
} catch (Exception e) {
e.printStackTrace();
}
回答1:
1) One way to filter *INQ messages is to use something like this:
MessageQueue queue = new MessageQueue(system, "/qsys.lib/qsysopr.msgq");
// want only inquiry messages
queue.setSelectMessagesNeedReply(true);
queue.setSelectMessagesNoNeedReply(false);
queue.setSelectSendersCopyMessagesNeedReply(true);
Enumeration e = queue.getMessages();
2) A message queue can be created in any library on the system. In order to get all messages from all message queues you will need to use ObjectList like this:
import java.util.*;
import com.ibm.as400.access.*;
public class TestObjectList {
public static void main(String[] args) {
try {
AS400 system = new AS400();
ObjectList msgqs = new ObjectList(system, ObjectList.ALL, ObjectList.ALL, "*MSGQ");
Enumeration e = msgqs.getObjects();
while (e.hasMoreElements()) {
ObjectDescription msgq = (ObjectDescription) e.nextElement();
System.out.println(msgq.getLibrary() + "/" + msgq.getName());
}
System.out.println("End of message queues.");
} catch (Exception e) {
e.printStackTrace();
}
System.exit(0);
}
}
来源:https://stackoverflow.com/questions/20078401/as-400-message-queue-filtering-jt400-java