RE: Purging Messsages

"Tim Anderson" <[email protected]>
Newsgroups gmane.comp.java.openjms.user
Message-ID <005201c556fe$46de1a90$7c7bfddc@xerces>
Try it - if it gets you round your immediate problem then go with it.
It will be fixed in the 0.7.7 release.
 
-Tim

-----Original Message-----
From: openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
[mailto:openjms-user-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org] On Behalf Of Ken M
Sent: Wednesday, 11 May 2005 3:31 AM
To: OpenJMS User
Subject: [openjms-user] Purging Messsages


Would it be acceptable to use this method to purge old messages from an
AdministeredTopic with non-durable subscribers?
It's use of internal exolab classes is a bit sticky, but ... 

<pre>
                  import org.exolab.jms.persistence;

                  java.sql.Connection c = DatabaseService.getConnection();
                  Messages m = Messages.instance();

                  Vector v = m.getUnprocessedMessages(c);

                  int x = 0;
                  for (Enumeration e = v.elements(); e.hasMoreElements(); )
                  {
                     Message mm = (Message)e.nextElement();

                     long time = mm.getJMSTimestamp();

                     // 30 minutes.
                     if (time < (now - 1800000))
                     {
                        m.remove(c, mm.getJMSMessageID());
                        x++;
                     }
                  }
                  c.commit();
                  SQLHelper.close(c);
</pre>
I ask because if this isn't the way - is there another that doesnt require
intimate knowledge of the datastore?  
(I could use the Connection directly and call SQL on it - but is this going
to hit me too?! )

Ken
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.