Get message from a local queue

The following code gets the "top" message from the local queue, SYSTEM.DEFAULT.LOCAL.QUEUE, checks that a message with the field myFieldName was obtained, and displays the text held in the Unicode field.

  public void get() throws Exception {
          System.out.println("Getting the test message.");
          MQeMsgObject msg = myQueueManager.getMessage( queueManagerName,
                                                        MQe.System_Default_Queue_Name,
                                                        null, null, 0L );

          if (msg != null) {
              System.out.println("Got the test message.");

              if (msg.contains("myFieldName")) {
                  String textGot = msg.getUnicode("myFieldName");

                  System.out.println("Message contained the text '" + textGot + "'");
              }
          }
      }

Terms of use | WebSphere software

(c) Copyright IBM Corporation 2004, 2005. All rights reserved.