1 2 Previous Next 25 Replies Latest reply on Jul 31, 2006 5:10 PM by Tim Fox

    Consumed messages redelivered ?

    Lakshmi Dasari Newbie

      I have configured Oracle persistence with Jboss messaging and I have created the tables required for persistence in Oracle database. It appears to me that the messages are redelivered even after the messages are successfully received and processed by the consumer.

      I believe that JMS_MESSAGES is the table which stores the JMS messages , now, when are the messages deleted from this table ? While I am sending a message, I am marking the message as persistent and creating a non-transacted session with Session.AUTO_ACKNOWLEDGE,

      Looking at the "STATE" column in the JMS_MESSAGES table, how can I verify if the messages are delivered successfully or they are waiting to be processed. In this particular case, all my messages have been marked "C" in the JMS_MESSAGES table. On server startup, my MessageListeners are picking up the messages again from the queue. Also does the 'MessageCount" in jmx-console indicate the total number of messages received at the queue or the number of messages yet to be processed ? Finally when is the acknowledgement sent in case when a Session is created with Session.AUTO_ACKNOWLEDGEMENT?

      My configuration:
      Jboss 4.0.3SP1
      Jboss message 1.0.1 CR2
      Oracle 10G

        • 1. Re: Consumed messages redelivered ?
          Tim Fox Master

          When persistent messages are acked they will be removed from the jms_message_reference table.

          When all references to the message (the same message can be in many queues or subscriptions) are acked, it will be removed from the jms_message table.

          MessageCount represents the total number of messages in the queue at that time.

          For auto acknowledgement the message is acked when the call to receive has returned or when the onMessage method has finished executing
          (see http://java.sun.com/j2ee/1.4/docs/api/index.html)

          If this is not what you are seeing please send me your code and I will take a look.

          • 2. Re: Consumed messages redelivered ?
            Lakshmi Dasari Newbie

            Firstly , when I debug into the code I see that no exceptions arise and onMessage invocation ends successfully. So I believe that my application is functioning correctly and the messages are processed successfully. Therefore an acknowledgement should have been sent thereby which the contents of the jms tables should have been deleted accordingly. But this has not happened.

            Second, If the messages have not received an acknowledgement, then when are the messages retried ? As long as the server is running, I dont see these messages that exist in the table to be processed again by the listeners. However, when I restart my server, these messages are being picked up by the listener. I am puzzled as my application works absolutely fine till the server is restarted !!

            Sending the code might be a bit clumsy as it spans across many files. If there is a way I can send the snapshot of JMS_MESSAGE and JMS_MESSAGE_REFERENCE tables which might aid debugging please let me know so.

            • 3. Re: Consumed messages redelivered ?
              Lakshmi Dasari Newbie

              Also please note that I have separated the "create table" sql statements from oracle-persistence.xml and have put them in a separate configuration file which I run before I start jboss. I have made the property "CreateTablesOnStartup" as false too and I have left the remaining sqls (INSERT, DELETE, UPDATE) statements as it is in the oracle-persistence.xml file. Now is this making any difference ?

              Now I believe that If I leave the create statements in the oracle persistence xml and leave the "CreateTablesOnStartup" property to true, then the tables are created on server startup. In this case, are the messages which were not delivered successfully lost on server restart?

              • 4. Re: Consumed messages redelivered ?
                Tim Fox Master

                Please replicate in a simple test case, and send to me and I will investigate.

                Thanks.

                • 5. Re: Consumed messages redelivered ?
                  Tim Fox Master

                  You don't have to send all your code. Just replicate with a simple message listener, this is the normal proceedure...

                  • 6. Re: Consumed messages redelivered ?
                    mskonda Apprentice

                     

                    "dv_lakshmi" wrote:
                    Also please note that I have separated the "create table" sql statements from oracle-persistence.xml and have put them in a separate configuration file which I run before I start jboss. I have made the property "CreateTablesOnStartup" as false too and I have left the remaining sqls (INSERT, DELETE, UPDATE) statements as it is in the oracle-persistence.xml file. Now is this making any difference ?


                    It shouldn't be. You can always create the tables according to your applicaiton installation or configuration policies(that is, you don't have to wait for the server to create the tables on startup at all). If the flag is set to true, the tables are created if and only if they are non-existent. If they are already existent (wheather you have created via a script or first time server startup), an debug exception is logged to say that the said table is already existing, but this is just a log statment that can be ignored!


                    Now I believe that If I leave the create statements in the oracle persistence xml and leave the "CreateTablesOnStartup" property to true, then the tables are created on server startup. In this case, are the messages which were not delivered successfully lost on server restart?

                    See above explanation about creating tables on startup.

                    Thanks
                    Madhu

                    • 7. Re: Consumed messages redelivered ?
                      mskonda Apprentice

                       

                      "dv_lakshmi" wrote:

                      Second, If the messages have not received an acknowledgement, then when are the messages retried ? As long as the server is running, I dont see these messages that exist in the table to be processed again by the listeners. However, when I restart my server, these messages are being picked up by the listener. I am puzzled as my application works absolutely fine till the server is restarted !!

                      Could you confirm that your transactions are committed? (You can check the state of the transaction in JMS_TRANSACTION table). If there exists a row, this indicates you have a uncomitted (prepared) tx.

                      Thanks
                      Madhu

                      • 8. Re: Consumed messages redelivered ?
                        Tim Fox Master

                        My guess is that you are using a transacted session and not committing, or using client acknowledge and not explicitly acknowledging.

                        Although without seeing a test case I can replicate I am just guessing.

                        • 9. Re: Consumed messages redelivered ?
                          Lakshmi Dasari Newbie

                           


                          Could you confirm that your transactions are committed? (You can check the state of the transaction in JMS_TRANSACTION table). If there exists a row, this indicates you have a uncomitted (prepared) tx.


                          JMS_TRANSACTION table is empty.

                          My guess is that you are using a transacted session and not committing, or using client acknowledge and not explicitly acknowledging.


                          createQueueSession(false,Session.AUTO_ACKNOWLEDGE)

                          Nope, The session is not transacted and is auto acknowledged .


                          I am working on isolating the problem using a smaller test case. Part of the complexity is because the application uses spring transaction management + jms listener plugin to register my queue listeners.


                          • 10. Re: Consumed messages redelivered ?
                            Tim Fox Master

                            BTW, are you using RC3? If not, I recommend upgrading to this version.

                            • 11. Re: Consumed messages redelivered ?
                              Lakshmi Dasari Newbie

                              I have tested on RC3 as well and the issue still persists.

                              • 12. Re: Consumed messages redelivered ?
                                Lakshmi Dasari Newbie

                                Tim, I have sent the source code by mail to your jboss account. Sorry, I forgot to mention how to run the application. Invoke "TunnelServlet" on a browser and it should send a message.

                                • 13. Re: Consumed messages redelivered ?
                                  Tim Fox Master

                                  Lakshmi-

                                  The test case you send me needs to have no spring dependencies. We can't spend our time debugging people's Spring applications :)

                                  I.e. straight JMS code

                                  • 14. Re: Consumed messages redelivered ?
                                    Lakshmi Dasari Newbie

                                    Well, part of the problem can be replicated even without the spring code. i.e., the message sending problem as mentioned in the email.

                                    1 2 Previous Next