6 Replies Latest reply on Jun 17, 2008 3:51 PM by clebert.suconic

    Remove old durable messages


      Is there a way that JBoss Messaging able to remove old durable messages from the Topic and from the db tables?

      For instance, my durable subscribers are no longer subscribe to the Topic but durable topic messages are still kept for them. How does JBoss Messaging handle this situation?

      Thanks,

        • 1. Re: Remove old durable messages
          clebert.suconic
          • 2. Re: Remove old durable messages

            From my client program [Durable Subscriber], it unsubscribes itself when it is shutting down.

            From the business point of view, my business partners don't want to receive messages from the Topic anymore. That means my business partners don't want to do business with me any more and don't want to subscribe to my application Durable Topic.

            Therefore, my application needs to remove all the messages of those no longer a partner [subscribers] to my company and my Durable Topic Publisher application.

            So, how do I go about to accomplish this task within JBoss Messaging without having to custom programming another home-grown application just to clean up JBoss Messaging old messages that clogs up the application memory?

            Hope that I have made my messages point of view to come across.

            Thanks,

            • 3. Re: Remove old durable messages
              clebert.suconic


              You shouldn't need to write any application to clean up old messages.

              When you remove the TopicSubscription, All the Message References to the Topic Subscription are deleted right away, and later the cleanup thread will delete orphaned Messages without references.


              ...just to clean up JBoss Messaging old messages that clogs up the application memory?


              Please don't be vague in your allegations. If you were more clear on the first post I wouldn't make the assumption you meant deleting message references and not the topic itself, and if you are pointing out a problem, we will gladly help any user. But general allegations without any supporting information will just waste our time (ours and yours)

              I'm not aware of your internal coding, and this is the first time I saw you asking about cleaning up of message references.

              So far it looks that everything some mistake from your side, so be careful or you could be flamed here :-)

              • 4. Re: Remove old durable messages
                clebert.suconic

                 

                So, how do I go about to accomplish this task within JBoss Messaging without having to custom programming another home-grown application just to clean up JBoss Messaging old messages that clogs up the application memory?


                I guess i was a bit paranoid about this. I'm sorry!

                When you unsubscribe the topic, as I said before, all the message references are removed.
                You could also use the method removeAllMessages on the MBean Topic if that applies.

                You also have a method listAllSubscriptions on the Topic MBean where you could validate your current subscription.

                Does that cover what you want to achieve?

                • 5. Re: Remove old durable messages

                  I'm appreciated your response.

                  This message is regarding of using TopicService class.
                  I have JBoss Messaging currently running with durable subscribers are subscribing to the Durable Topic. As you mentioned, we could use TopicMBean which is an 'interface' and TopicService that is implementing the TopicMBean.
                  However, when I tested the following codes it returned a NullPointerException.
                  TopicService service = new TopicService();
                  List list = service.listDurableMessages("sub-id");

                  list is returned as Null, even though there are durable messages in the DB table and Topic.
                  What have I missed from using the TopicService class?

                  Thanks again.

                  • 6. Re: Remove old durable messages
                    clebert.suconic

                     

                    TopicService service = new TopicService();
                    List list = service.listDurableMessages("sub-id");


                    You should use the TopicService through the JMX-Console (http://wiki.jboss.org/auth/wiki/JMXConsole)

                    Or you should look up the MBean through JNDI if you want to use the API.


                    There is this MBean FAQ which I found it pretty useful for what you need:

                    http://wiki.jboss.org/auth/wiki/FAQJBossJMX

                    In special:

                    http://wiki.jboss.org/wiki/HowCanAnEJBCallAnMBean

                    You should find information on how a Java client can call an MBean also.


                    Instantiating TopicService will certainly cause a NPE as you won't have all the bootstrap introduced by the Server start and other dependencies.