Purging Messsages
Ken M <wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]>
| Newsgroups | gmane.comp.java.openjms.user |
|---|---|
| Message-ID | <[email protected]> |
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