提前致谢!
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();
}
答案 0 :(得分:4)
1)过滤* INQ消息的一种方法是使用以下内容:
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)可以在系统上的任何库中创建消息队列。为了从所有消息队列中获取所有消息,您需要使用ObjectList,如下所示:
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);
}
}