コード例 #1
0
  public Map<String, Object>[] listMessages(final String filterStr) throws Exception {
    checkStarted();

    clearIO();
    try {
      Filter filter = FilterImpl.createFilter(filterStr);
      List<Map<String, Object>> messages = new ArrayList<Map<String, Object>>();
      queue.flushExecutor();
      LinkedListIterator<MessageReference> iterator = queue.iterator();
      try {
        while (iterator.hasNext()) {
          MessageReference ref = iterator.next();
          if (filter == null || filter.match(ref.getMessage())) {
            Message message = ref.getMessage();
            messages.add(message.toMap());
          }
        }
        return messages.toArray(new Map[messages.size()]);
      } finally {
        iterator.close();
      }
    } catch (HornetQException e) {
      throw new IllegalStateException(e.getMessage());
    } finally {
      blockOnIO();
    }
  }
コード例 #2
0
  public Map<String, Object>[] listScheduledMessages() throws Exception {
    checkStarted();

    clearIO();
    try {
      List<MessageReference> refs = queue.getScheduledMessages();
      Map<String, Object>[] messages = new Map[refs.size()];
      int i = 0;
      for (MessageReference ref : refs) {
        Message message = ref.getMessage();
        messages[i++] = message.toMap();
      }
      return messages;
    } finally {
      blockOnIO();
    }
  }