9 Replies Latest reply on Sep 19, 2002 1:54 PM by codonnell

    Duplicate Messages On JBOSS Restart

    karin608

      In my class when my listener picks up a message from my queue it is processed, then when jboss is stopped/restarted, the prior message is picked up again as if it had never been consumed the first time. This happens every time, no matter how many days between restarts.
      Can anyone tell me how to keep this from happening?

      Thanks in advance.
      Karin

        • 1. Re: Duplicate Messages On JBOSS Restart
          joelvogt

          Is your session set up to have
          Session.AUTO_ACKNOWLEDGE?
          Otherwise make sure you are acknowledgeing the message as it comes through with
          message.acknowledge();

          • 2. Re: Duplicate Messages On JBOSS Restart
            karin608

            Thanks for the quick reply.
            I was using AUTO_ACKNOWLEDGE while having this problem. So then I tried CLIENT_ACKNOWLEDGE and did the message.acknowledge() myself. This still did not work.
            I had also read where you can check the JMSRedelivered flag using message.getJMSRedelivered(), but it returns 'false' even for the duplicate message. I also know that we did not have this problem while using SwiftMQ, it only started when we had to switch to the JBossMQ for an unrelated matter.
            Would you have any other ideas I could try?
            Thanks,
            Karin

            • 3. Re: Duplicate Messages On JBOSS Restart
              joelvogt

              mmm, one thing is to make sure that your onMessage method cannot throw an exception (all have to be caught).
              Other than that check both publisher and subscriber have something like
              TopicSession topicSession = topicConnection.createTopicSession(false,
              Session.AUTO_ACKNOWLEDGE);

              • 4. Re: Duplicate Messages On JBOSS Restart
                karin608

                I checked those two items and they're ok.
                I believe I have narrowed it down to something specific.
                My class picks up messages from 1 queue, saves the data to a database, then writes the message to a 2nd (different) queue. If you take the last part out of the equation (i.e. do not write it to the next queue), then it does not duplicate. Put that part back, and it does duplicate. I really can't imagine why that would cause a problem. Weird huh?

                • 5. Re: Duplicate Messages On JBOSS Restart
                  karin608

                  I checked those two things and they're ok.
                  I think I have narrowed it down to something specific.
                  My class uses 2 queues. It receives an ObjectMessage from the 1st queue, writes the data contained in the message to a database, then writes the same ObjectMessage to a second (different) queue.
                  If I take that last part out (i.e. do not write the message to the 2nd queue), then I do not get duplicates when JBoss restarts. If I put that part back, I get the duplicates. I can't imagine why that is causing me problems?!?!
                  Weird huh?

                  • 6. Re: Duplicate Messages On JBOSS Restart
                    karin608

                    I checked those two things and they're ok.
                    I think I have narrowed it down to something specific.
                    My class uses 2 queues. It receives an ObjectMessage from the 1st queue, writes the data contained in the message to a database, then writes the same ObjectMessage to a second (different) queue.
                    If I take that last part out (i.e. do not write the message to the 2nd queue), then I do not get duplicates when JBoss restarts. If I put that part back, I get the duplicates. I can't imagine why that is causing me problems?!?!
                    Weird huh?

                    • 7. Re: Duplicate Messages On JBOSS Restart
                      cepage

                      This is a known bug that has supposedly been fixed in the 3.0 series. The workaround in the 2.4.x series is not to take the message out of one queue and directly put it in the second queue.

                      Rather, when you take the message out of the first queue, create a second message. Copy the contents of the first message into the second message, and put the second message into the second queue. Now you won't experience the problem.

                      Corby

                      • 8. Re: Duplicate Messages On JBOSS Restart
                        karin608

                        That worked! Thanks so much to all for the help!
                        Karin

                        • 9. Re: Duplicate Messages On JBOSS Restart
                          codonnell

                          Hi,

                          I am experiencing the same problem when using two queues.
                          However the code creates a new message instance and changes so of the message data and the duplicate message problem still exists.

                          I am using JBOSS jboss-3.0.0_tomcat-4.0.3

                          Any ideas?

                          Thanks in advance