activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <james.strac...@gmail.com>
Subject Re: Temporary destinations with given destination name
Date Tue, 10 Jul 2007 07:59:33 GMT
On 7/10/07, James Strachan <james.strachan@gmail.com> wrote:
> On 7/9/07, happyAMQ <jbenderl@olf.com> wrote:
> >
> > This sounds ideal.  Can you point me to some docs on how to write a plugin?
>
> Here's some documentation...
> http://activemq.apache.org/interceptors.html
> http://activemq.apache.org/developing-plugins.html
>
> its probably easiest to look at the code for some existing plugins to
> get the idea.
>
> I think this will be a useful addition; do you fancy contributing your
> plugin to the project?
> http://activemq.apache.org/contributing.html
>
>
> > Would I be using the same JMX method to delete the destinations in this
> > plugin?
>
> You could do; though a BrokerPlugin has access to the real broker...
>
> http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/broker/Broker.html
>
> so you can tinker directly with whatever you like.
>
> Note that its the getDestinationMap() you'll be using on the base
> Region interface to introspect the available Destination objects, to
> get the DestinatioStatistics (to check for empty queues with no
> consumers).
>
> You probably wanna keep a cache in your plugin; for each destination
> cache the enqueue counts for empty destinations with no consumers. In
> pseudocode...

Whoops - dunno what happened there, I hit send before I'd finished :)

So this is the pseudocode I was thinking really is...

onTimer() {
for (Destination d) {
 if (d.destinationStats.messages == 0 && d.destinationStats.consumers == 0) {
    enqueueCount = cache.get(d);
    if (enqueueCount != null && enqueueCount ==
d.destinationStats.enqueueCount) {
        // no activity within a timeout period so lets delete
        removeDestination(d);
    }
    else {
        cache.put(d, enqueueCount);
   }
}
}

removeDestination(d) {
   // lets clean up our cache
   cache.remove(d);
   super.removeDestination(d)
}


i.e. we want a timer to fire to detect the empty destinations with no
consumers; then if in the subsequent timer period, no messages have
been dispatched and we still have no consumers, then zap the
destination.

-- 
James
-------
http://macstrac.blogspot.com/

Mime
View raw message