You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by happyAMQ <jb...@olf.com> on 2007/07/06 21:28:09 UTC

Temporary destinations with given destination name

Hi,
Is it possible to create temporary destinations with a given name,  instead
of having ActiveMQ creating a name?

For example, 
createTemporaryQueue("My.Chosen.Name");

Thanks,
Jason.
-- 
View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a11471152
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Temporary destinations with given destination name

Posted by asaburov <al...@gmail.com>.
James,

I have implemented the plugin that 1) runs on the predefined schedule 2)
cleans all the destinations that are without producers, consumers and
pending messages 3) will start after defined delay so to avoid removing
destinations defined through configuration file. 

Would like contribute that to the project if anyone interested. 

Do I move to Dev forum to discuss details now? 

Aleksey. 


James.Strachan wrote:
> 
> On 7/10/07, James Strachan <ja...@gmail.com> wrote:
> 
> So this is the pseudocode I was thinking really is...
> 
> <...>
> 
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a12239404
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Temporary destinations with given destination name

Posted by happyAMQ <jb...@olf.com>.
Hi,

-->do you fancy contributing your plugin to the project? 
I would like nothing better than to contribute back to open source.  I will
first have to clear it with the 'suits' at my company.  They have approved
previous  stuff.

-->if (d.destinationStats.messages == 0 && d.destinationStats.consumers ==
0) { 
I would also need to check if a destination has any producers before
removing the destination,  but this is not part of destinationStats.  Think
of the case where a process is up and running but might send a message on a
topic that no one at a point is time is listening on - I can't remove that
destination.

Jason
-- 
View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a11530672
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Temporary destinations with given destination name

Posted by James Strachan <ja...@gmail.com>.
On 7/10/07, James Strachan <ja...@gmail.com> wrote:
> On 7/9/07, happyAMQ <jb...@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/

Re: Temporary destinations with given destination name

Posted by James Strachan <ja...@gmail.com>.
On 7/9/07, happyAMQ <jb...@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...

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);
     }

     if (cache.contains(d)) {


So that each time a timer fires, you can look for all empty
destinations with no consumers; if you've cache; so that when each

>
> Thanks!
> Jason.
>
>
>
> -->  Another option is to write a little broker plugin to eagerly delete
> any broker-side destinations which are not being used by any clients
> within some time period. e.g. if no client uses a particular
> destination within say 10 seconds (and the destination is empty), then
> just zap it.
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
>
>
> --
> View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a11511275
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


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

Re: Temporary destinations with given destination name

Posted by happyAMQ <jb...@olf.com>.
This sounds ideal.  Can you point me to some docs on how to write a plugin? 
Would I be using the same JMX method to delete the destinations in this
plugin?

Thanks!
Jason.



-->  Another option is to write a little broker plugin to eagerly delete
any broker-side destinations which are not being used by any clients
within some time period. e.g. if no client uses a particular
destination within say 10 seconds (and the destination is empty), then
just zap it.

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



-- 
View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a11511275
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Temporary destinations with given destination name

Posted by James Strachan <ja...@gmail.com>.
On 7/9/07, happyAMQ <jb...@olf.com> wrote:
>
> I'm trying to re-create Tibco Rendezvous (RV) semantics,  where destinations
> (subjects in RV) are not administered objects and don't hang out in the
> broker when there aren't any connections using that destination (just like
> temporary destinations).  But I need to have specific destination names so
> that client's know what name to send messages on.
>
> -->Otherwise why not just create a regular destination and zap it when you
> want?
>
> This could work on the Java side of things because of the the JMX classes
> you pointed me to,  but I also have to do this on a C# platform with NMS.
> Is this supported?
>
> FYI,  I'm building a cross-platform (Java, C#, C/C++) ESB with binary
> messages (not XML).

Another option is to write a little broker plugin to eagerly delete
any broker-side destinations which are not being used by any clients
within some time period. e.g. if no client uses a particular
destination within say 10 seconds (and the destination is empty), then
just zap it.

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

Re: Temporary destinations with given destination name

Posted by happyAMQ <jb...@olf.com>.
I'm trying to re-create Tibco Rendezvous (RV) semantics,  where destinations
(subjects in RV) are not administered objects and don't hang out in the
broker when there aren't any connections using that destination (just like
temporary destinations).  But I need to have specific destination names so
that client's know what name to send messages on.

-->Otherwise why not just create a regular destination and zap it when you
want? 

This could work on the Java side of things because of the the JMX classes
you pointed me to,  but I also have to do this on a C# platform with NMS. 
Is this supported?

FYI,  I'm building a cross-platform (Java, C#, C/C++) ESB with binary
messages (not XML).

Thanks,

Jason.

-- 
View this message in context: http://www.nabble.com/Temporary-destinations-with-given-destination-name-tf4037658s2354.html#a11510576
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Temporary destinations with given destination name

Posted by James Strachan <ja...@gmail.com>.
On 7/6/07, happyAMQ <jb...@olf.com> wrote:
>
> Hi,
> Is it possible to create temporary destinations with a given name,  instead
> of having ActiveMQ creating a name?
>
> For example,
> createTemporaryQueue("My.Chosen.Name");

No. Temporary queues have to be unique to the entire JMS network to a
specific connection; otherwise clashes could occur.

If its a temporary thing, why do you care what the name is btw?

Otherwise why not just create a regular destination and zap it when you want?
-- 
James
-------
http://macstrac.blogspot.com/