AS/400 Message queue filtering - JT400 (JAVA)

十年热恋 提交于 2019-12-10 23:39:33

问题


  1. 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 ?
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!