4 Replies Latest reply on Nov 10, 2014 11:47 AM by Justin Bertram

    Get messages list (including scheduled) with using filter

    Ivan Orlov Newbie

      Hello, I add delivered jobs to my hornetq:

      public void sendJmsEvent(String queueName, NotificationMessage notificationMessage) {
        jmsTemplate.send("queue", new MessageCreator() {
          public Message createMessage(Session session) throws JMSException {
            Message message = session.createObjectMessage(someObject);
            message.setStringProperty("LOGIN", currentUserLogin);
            message.setLongProperty("_HQ_SCHED_DELIVERY", sometimesInFuture);
            return message;


      And now I want to get list of messages by filter "LOGIN=user97801".


      I explore this document:




      And write this code:



      private ConnectionFactory connectionFactory;


      public void listMessages(String filter) {

        try {

          final Queue managementQueue = HornetQJMSClient.createQueue("hornetq.management");

          Connection connection = connectionFactory.createConnection();

          Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

          QueueRequestor requestor = new QueueRequestor((QueueSession) session, managementQueue);


          Message message = session.createMessage();

          JMSManagementHelper.putOperationInvocation(message, ResourceNames.JMS_QUEUE + "templateEmailQueue", "listMessages", null);

          Message reply = requestor.request(message);

          if (JMSManagementHelper.hasOperationSucceeded(reply)) {

            for (Object arrayQueue : JMSManagementHelper.getResults(reply)) {

              System.out.println("Length: "+((Object[])arrayQueue).length);

              for (Object queue : (Object[]) arrayQueue) {

                System.out.println("Message" + queue);




          return null;

        } catch(Exception e) {





      but it returns only messages what is actually in the queue and ignores my scheduled messages.

      I can't use listScheduledMessages method instead, because there is no filter as an argument, I can't parametrize search condition.


      Is there some solution of my case? Is it correct that listMessages doesn't include scheduled messages?