4 Replies Latest reply: Feb 22, 2012 4:31 PM by Tino Sainz RSS

Strange behaviour in HornetQ 2.2.2

Tino Sainz Newbie

I dont know if this is a bug (and excuse me if its already posted, but with my limited english i couldnt explain it with enough acuraccy for a search), but i would like to know why this happens, its on hornetQ 2.2.2 (if this is not supossed to happen, ill test it on last version).

 

My main objetive is to build a debug-process which can delete a message by ID (i obtain id comparing toStrings via a browser and calling getJMSMessageID() of the Message), i cant control/enable JMX-MBeans and such on server (i'm wrong?, they wont ALLOW me to open jmx, so i can only use JMS classes and such, not mbeans nor jmx).

 

Having 100 messages whose toString() representation its "object70, object71, object72, object73...."

 

My ID is the one corresponding to message number 80(object80).

 

With this code (session is a normal session, non-transacted, auto-ack etc...) and colaLectura is my queue object:

 

         int resul = 0;

        System.out.println("Filter:" +  filtro);

        QueueReceiver recv = session.createReceiver(colaLectura, filtro);

        while (recv.receiveNoWait() != null) {           

            Message m=recv.receiveNoWait(); <-- I know im calling this method twice and its not right, but well, you get the idea.

            System.out.println("Got message with ID:" +  m.getJMSMessageID() + "--> toString:" +((TextMessage)m).getText());

            resul++;

        }

        recv.close();

        return resul;

 

My output is this:

Filter:JMSMessageID='ID:75a17aaa-5d71-11e1-9c2a-001109ca9526'

Got message with ID:ID:75a17aaa-5d71-11e1-9c2a-001109ca9526 --> toString: objeto80

Got message with ID:ID:75a17aaa-5d71-11e1-9c2a-001109ca9526 --> toString: objeto80

Got message with ID:ID:75a17aaa-5d71-11e1-9c2a-001109ca9526 --> toString: objeto80

Got message with ID:ID:75a17aaa-5d71-11e1-9c2a-001109ca9526 --> toString:objeto80

Got message with ID:ID:75a17aaa-5d71-11e1-9c2a-001109ca9526 --> toString:objeto80

 

It returns 10 instances of my desired message, (there is only one on the queue of course), and all messages 70-80 disappear @ the queue (BUT, all except objeto80 one, are still there, messageCounter shows them, but i'll never be able to get them, unless i restart hornetq server). <-- Test is done on my own server, i cant access messageCounter on production machine.

 

Thanks for reading and/or answering,

 

PD: Any workaround-idea to delete message by ID without using jmx/mbeans removeMessage method? without consuming every message and re-sending all of them except the one i want to delete.

  • 1. Re: Strange behaviour in HornetQ 2.2.2
    Clebert Suconic Master

    I just tried with a similar code on 2.2.latest and it worked fine.

     

    You are doing some mess with that code.. it's hard to understand what's going on there. (especially on the receiveNoWait that you;re calling since that will remove a message that you will never see)

  • 2. Re: Strange behaviour in HornetQ 2.2.2
    Tino Sainz Newbie

        int resul = 0;

            System.out.println("Filter:" +  filtro);

            QueueReceiver recv = session.createReceiver(colaLectura, filtro);
              Message m=null;

            while ((m=recv.receiveNoWait()) != null) {           

                System.out.println("Got message with ID:" +  m.getJMSMessageID() + "--> toString:" +((TextMessage)m).getText());

                resul++;

            }

            recv.close();

            return resul;

     

    Better now? , result is the same, 10 lines showing me the same ID and the same content.

     

    I want to consume the message with ID 'ID:75a17aaa-5d71-11e1-9c2a-001109ca9526'

     

    Using this filter: JMSMessageID='ID:75a17aaa-5d71-11e1-9c2a-001109ca9526'

     

    But when i try to consume it, the filter will return 10 messages (the ones which are ahead of it on the queue) with the same ID and content than the one i want to delete (it only should return one right?), and it makes all of those 10 messages disappear (not really, at the end, only the one i want disappears, aka queue size goes -1, but if i want to consume the other 9, i'll have to restart hornetq, they are locked.

     

    I'll try to do a full testcase now (im at home, code is @ work).

  • 3. Re: Strange behaviour in HornetQ 2.2.2
    Clebert Suconic Master

    You should add your own ID and consume based on that.

     

    You could use management API over JMS (You don't need to use JMX). Look at the examples.

     

    BTW: You're using a messaging system like a database (like querying the queue, deleting queues. etc).. that approach usually fails on any message system.

  • 4. Re: Strange behaviour in HornetQ 2.2.2
    Tino Sainz Newbie

    Ok, i tested code again at home, and it works fine, i dont know what's happening @ work, but ill have to check next day (also server, some configuration changes there ). Sorry

     

    The real usage of the system is normal one (really basic, put object in queue, next process gets it, processes message and puts it at other queue, another one gets it...), but people @ production dont have a clue about queues/hornetq, etc..., and they wont enable JMX and let us access, so im trying to do a simple process which helps us monitoring/debugging/unlocking queues there :/ (and one of those "utilities" is deleting a custom message). Thats why i cant put my custom properties too (cant modify real processes which use queues), only use those ones.

     

    I tried with QueueControl, it gave me object not found so i thought it was using JMX, i'll have to check deeper in a future, thanks.