You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by carlosfocker <ca...@gmail.com> on 2010/04/14 18:35:17 UTC

Topic Inheritance

Does ActiveMQ allow for topics to have parent topics?  For example, a parent
topic Car might have two child topics called Ford and Nissan.  If a
publisher publishes a message to the Car topic, both Ford and Nissan
subscribers would receive the message.  If a message is published to the
Nissan topic, only Nissan topic subscribers would receive the message.
-- 
View this message in context: http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic Inheritance

Posted by Bruce Snyder <br...@gmail.com>.
On Wed, Apr 14, 2010 at 10:20 PM, go canal <go...@yahoo.com> wrote:
> this solves my chat room use case also, thanks. I did not realize this feature, did not remember JMS has this.

JMS does not offer this feature. This is an ActiveMQ-specific feature.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: Topic Inheritance

Posted by Bruce Snyder <br...@gmail.com>.
On Thu, Apr 15, 2010 at 12:55 AM, go canal <go...@yahoo.com> wrote:
> thanks for the examples.
>
> just wanted to make sure if my understanding is correct:
>  * is to match any name, including empty name;
>  > is to match any name (not for empty?) and hierarchy.
>
> So
>
>  a.* means 'a.' followed by one or zero hierarchy.
>  a.> means 'a.' followed by one or more levels of hierarchy.
>
> am I correct ?

Correct.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: Topic Inheritance

Posted by go canal <go...@yahoo.com>.
thanks for the examples. 

just wanted to make sure if my understanding is correct:
 * is to match any name, including empty name; 
 > is to match any name (not for empty?) and hierarchy.

So 

 a.* means 'a.' followed by one or zero hierarchy.
 a.> means 'a.' followed by one or more levels of hierarchy. 
 
am I correct ?
rgds,
canal




________________________________
From: Sebastian Rodriguez <sr...@gmail.com>
To: users@activemq.apache.org
Sent: Thu, April 15, 2010 1:38:10 PM
Subject: Re: Topic Inheritance

Hi canal,
Yes, car.ford.> and car.ford.* will receive the same messages.

The difference is that for example you want to receive all the messages
concerning truck, *.*.truck will make the trick :)

For the difference between * and > maybe this other example will help you
understand:

a.b.c
a.b.d
a.e.c


   - if you subscribe to a.> you will receive everything sent to "a.b.c",
   "a.b.d", "a.e.c", "a.b", "a.e", "a"
   this will be equivalent as a.*.*


   - if you subscribe to a.b.> you will receive messages sent to "a.b.c",
   "a.b.d", "a.b"
   this is equivalent of subscribing to a.b.*


   - The problem comes if, let's say, you want to subscribe to "everything
   that ends with c"
   you will have to subscribe to "*.*.c" This is not translatable to a ">"
   expression.

You might ask yourself: then, why use the ">" if i can always translate it
to "*" expression. Well, sometimes you simply dont know the depth of the
childs, and it's more error proof. I would rather subscribe to "lambda.>"
than to "lambda.*.*.*.*.*" for eg

Hope this has clarified your doubts!


On 15 April 2010 12:20, go canal <go...@yahoo.com> wrote:

> this solves my chat room use case also, thanks. I did not realize this
> feature, did not remember JMS has this.
>
> A question wrt > and *, not very clear about these two: if I have
> car.ford.suv, car.ford.truck
>
> are these two the same:
>  car.ford.>
>  car.ford.*
>
>  rgds,
> canal
>
>
>
>
> ________________________________
> From: Rob Davies <ra...@gmail.com>
> To: users@activemq.apache.org
> Sent: Thu, April 15, 2010 8:51:50 AM
> Subject: Re: Topic Inheritance
>
> Yes - ActiveMQ supports destination hierarchies  - a '.' dot notation
> denotes an element in the name.
> To extend your example - say you had models too - to subscribe to all Ford
> cars - you would use '>'.  e.g. car.ford.>
> You can use the '*' to subscribe to everything for
> So to subscribe to cars - you would subscribe to the topic car.>
> To subscribe to all cars of type mondeo - you would subscribe to
> car.*.modeo - or *.*.mondeo
>
> Hope that makes sense ?
> On 14 Apr 2010, at 17:35, carlosfocker wrote:
>
> >
> > Does ActiveMQ allow for topics to have parent topics?  For example, a
> parent
> > topic Car might have two child topics called Ford and Nissan.  If a
> > publisher publishes a message to the Car topic, both Ford and Nissan
> > subscribers would receive the message.  If a message is published to the
> > Nissan topic, only Nissan topic subscribers would receive the message.
> > --
> > View this message in context:
> http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
>
>
>
>



-- 
Sebastien Rodriguez



      

Re: Topic Inheritance

Posted by Sebastian Rodriguez <sr...@gmail.com>.
Hi canal,
Yes, car.ford.> and car.ford.* will receive the same messages.

The difference is that for example you want to receive all the messages
concerning truck, *.*.truck will make the trick :)

For the difference between * and > maybe this other example will help you
understand:

a.b.c
a.b.d
a.e.c


   - if you subscribe to a.> you will receive everything sent to "a.b.c",
   "a.b.d", "a.e.c", "a.b", "a.e", "a"
   this will be equivalent as a.*.*


   - if you subscribe to a.b.> you will receive messages sent to "a.b.c",
   "a.b.d", "a.b"
   this is equivalent of subscribing to a.b.*


   - The problem comes if, let's say, you want to subscribe to "everything
   that ends with c"
   you will have to subscribe to "*.*.c" This is not translatable to a ">"
   expression.

You might ask yourself: then, why use the ">" if i can always translate it
to "*" expression. Well, sometimes you simply dont know the depth of the
childs, and it's more error proof. I would rather subscribe to "lambda.>"
than to "lambda.*.*.*.*.*" for eg

Hope this has clarified your doubts!


On 15 April 2010 12:20, go canal <go...@yahoo.com> wrote:

> this solves my chat room use case also, thanks. I did not realize this
> feature, did not remember JMS has this.
>
> A question wrt > and *, not very clear about these two: if I have
> car.ford.suv, car.ford.truck
>
> are these two the same:
>  car.ford.>
>  car.ford.*
>
>  rgds,
> canal
>
>
>
>
> ________________________________
> From: Rob Davies <ra...@gmail.com>
> To: users@activemq.apache.org
> Sent: Thu, April 15, 2010 8:51:50 AM
> Subject: Re: Topic Inheritance
>
> Yes - ActiveMQ supports destination hierarchies  - a '.' dot notation
> denotes an element in the name.
> To extend your example - say you had models too - to subscribe to all Ford
> cars - you would use '>'.  e.g. car.ford.>
> You can use the '*' to subscribe to everything for
> So to subscribe to cars - you would subscribe to the topic car.>
> To subscribe to all cars of type mondeo - you would subscribe to
> car.*.modeo - or *.*.mondeo
>
> Hope that makes sense ?
> On 14 Apr 2010, at 17:35, carlosfocker wrote:
>
> >
> > Does ActiveMQ allow for topics to have parent topics?  For example, a
> parent
> > topic Car might have two child topics called Ford and Nissan.  If a
> > publisher publishes a message to the Car topic, both Ford and Nissan
> > subscribers would receive the message.  If a message is published to the
> > Nissan topic, only Nissan topic subscribers would receive the message.
> > --
> > View this message in context:
> http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
> > Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> >
>
>
>
>



-- 
Sebastien Rodriguez

Re: Topic Inheritance

Posted by go canal <go...@yahoo.com>.
this solves my chat room use case also, thanks. I did not realize this feature, did not remember JMS has this. 

A question wrt > and *, not very clear about these two: if I have car.ford.suv, car.ford.truck

are these two the same:
  car.ford.>
  car.ford.*

 rgds,
canal




________________________________
From: Rob Davies <ra...@gmail.com>
To: users@activemq.apache.org
Sent: Thu, April 15, 2010 8:51:50 AM
Subject: Re: Topic Inheritance

Yes - ActiveMQ supports destination hierarchies  - a '.' dot notation denotes an element in the name.
To extend your example - say you had models too - to subscribe to all Ford cars - you would use '>'.  e.g. car.ford.>
You can use the '*' to subscribe to everything for 
So to subscribe to cars - you would subscribe to the topic car.> 
To subscribe to all cars of type mondeo - you would subscribe to car.*.modeo - or *.*.mondeo

Hope that makes sense ?
On 14 Apr 2010, at 17:35, carlosfocker wrote:

> 
> Does ActiveMQ allow for topics to have parent topics?  For example, a parent
> topic Car might have two child topics called Ford and Nissan.  If a
> publisher publishes a message to the Car topic, both Ford and Nissan
> subscribers would receive the message.  If a message is published to the
> Nissan topic, only Nissan topic subscribers would receive the message.
> -- 
> View this message in context: http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> 


      

Re: Topic Inheritance

Posted by Rob Davies <ra...@gmail.com>.
Yes - ActiveMQ supports destination hierarchies  - a '.' dot notation denotes an element in the name.
To extend your example - say you had models too - to subscribe to all Ford cars - you would use '>'.  e.g. car.ford.>
You can use the '*' to subscribe to everything for 
So to subscribe to cars - you would subscribe to the topic car.> 
To subscribe to all cars of type mondeo - you would subscribe to car.*.modeo - or *.*.mondeo

Hope that makes sense ?
On 14 Apr 2010, at 17:35, carlosfocker wrote:

> 
> Does ActiveMQ allow for topics to have parent topics?  For example, a parent
> topic Car might have two child topics called Ford and Nissan.  If a
> publisher publishes a message to the Car topic, both Ford and Nissan
> subscribers would receive the message.  If a message is published to the
> Nissan topic, only Nissan topic subscribers would receive the message.
> -- 
> View this message in context: http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> 


Re: Topic Inheritance

Posted by carlosfocker <ca...@gmail.com>.
All the answers provided help.

-- 
View this message in context: http://old.nabble.com/Topic-Inheritance-tp28245081p28255890.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Topic Inheritance

Posted by Sebastian Rodriguez <sr...@gmail.com>.
Dear Carlos,
You should have a look at the wildcard subscriptions:
http://activemq.apache.org/wildcards.html
<http://activemq.apache.org/wildcards.html>It's more the other way around
though: you publish to a specific topic and all the parent's subscribers
will receive it, instead of publishing to a parent and all the child
subscribers will receive it.

In your example, you could have:
Car.Japanese.Nissan
Car.Japanese.Mazda
Car.American.Ford
Car.American.Chrysler

if you publish to Nissan, subscribers to Car.> or Car.Japanese.> or
Car.Japanese.Nissan or Car.*.Nissan will receive the message.
It's not exactly what you are asking for, but you will obtain the same
results.

Hope it helps!

On 15 April 2010 00:35, carlosfocker <ca...@gmail.com> wrote:

>
> Does ActiveMQ allow for topics to have parent topics?  For example, a
> parent
> topic Car might have two child topics called Ford and Nissan.  If a
> publisher publishes a message to the Car topic, both Ford and Nissan
> subscribers would receive the message.  If a message is published to the
> Nissan topic, only Nissan topic subscribers would receive the message.
> --
> View this message in context:
> http://old.nabble.com/Topic-Inheritance-tp28245081p28245081.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>


-- 
Sebastien Rodriguez