Closed ppurang closed 10 years ago
I wanted messages to cascade down the topic tree because it allows easy broadcast on subtopics.
When a message is received it contains the topic on which it was initially pushed in the field "event". This way, the client can still filter those "broadcast" messages.
So subscribing to "/topics/animals/furry/cats" you could receive
id: 11345 event: /animals/furry data: A message for all furry animals! timestamp: 1388250283
and decide dynamically according your use case to do something with it or not.
You are not the first one to ask about this design decision, so I guess it is not really intuitive for a pubsub engine.
But there is no way of getting to all animals messages right?
SO to be able to listen to all furry messages, I need to discover any newly added topics
/topics/animals/furry/cats /topics/animals/furry/dogs /topics/animals/furry/wombats etc.
to be able to listen to all furry messages. Right?
So now we need a way to discover new topics (recently added). Perhaps there is already some way of doing that. A message up the tree would not require that.
And it seems like other devs have the same model of thinking about it.
Actually you can listen to "/topic/animals/furry" and you will receive every message pushed to sub topics even if those are created after your subscription. This is done by propagating updates down and up the topic tree.
When a message is pushed to a specific topic it will be visible by all parents and by all children.
But I understand your point, so I will think about something to make the propagation strategy configurable.
I have two ideas possible to bring more flexibility. Tell me which one you makes more sense to you.
1) The propagation strategy is defined at the producer level :
2) The propagation strategy is defined at the consumer level :
WDYT?
You're building an message server whose unique feature is "Topic hierarchies and subscriptions" so you shouldn't aim to rebuild yet another message server with the same semantics. Plus i like the idea of downwards broadcasting.
I like the second approach most, but maybe you could give the subscriber even more freedom. Let him decide from how far upwards the hierarchy he likes to receive messages.
I really like your idea @oheidemann .
Giving more power to the subscriber is indeed an interesting way of building it, especially if we can come up with a generic way of describing the "how far upwards the hierarchy".
Something like
GET /topics/animals/furry/cat?scope=1
WDYT?
probably, i would name it "depth" and make it zero based, but yes basically that's what i was thinking about.
Ok for zero based :+1:
If you work with trees, depth has the semantic of "going down", here we are "extending" our interest upwards, so I am not entirely convinced.
Of course it is really a detail ;)
yeah, although depth has many more meanings, it is somewhat preasigned with going down.
so use level or upscope ( even if it isn't a real word ;-) )
We could even go further "down" that path. What about an API that could let you define you subscription "scope" in both direction
GET /topics/animals/furry?up=1&down2
Here you specify your interest in :
With default value up=0 and down=infinite
Hi all ;) I join this intersting question to give my understanding. i'd rather opt to 'scope' as we talk with the bidrectional up and down communication;we could think about a restriction like upscope and depth for up and down unilateral communication respectively.
It could offer some interesting power like give for an existing topics/animals/funny/cats a subscription on /animals/funny?upscope=0&depth=1 will give all funny cats, dogs, fish, ... but not the funny/cats/simons by example.
Great minds think alike ;)
I am not completely sure with the default values; but it could be part of the configuration ;) for me scope is over the up/down configuration.
omnibus { up : -1, // infiinite down : -1 // inifnite }
when a scope=s is defined, it will be equivalent to up=s&down=s.
Yes, that's what i was thinking too first, but i couldn't see the use case for limiting the scope downside.
Sounds good to me. The subscriber API starts to become quite rich, with the 'reactiveMode' we could have things like
GET /topics/animals/furry/+/videos/youtube/cute?up=1&down2&mode=between-id&since=1&from=3
It feels like we are creating some kind of REST SQL :D
I see a lot of discussion which is great. Here are my 2c
On a lighter note, as NSA I want to hear all messages on all topics in the tree ;)
I hope it all makes sense. Perhaps I am missing something crucial and have gotten the entire concept of tree like addresses/topics all wrong.
Thank @ppurang for bringing some insights to the thread, you perfectly understand the use case.
1 - totally agree with simplicity 2 - yes, we kind of decided to discard the possibility to offer a rich API on the producer side. 3 - this is the difficult API to design. We are trying to design a ""new"" way of doing pub/sub without getting too far away from the existing solutions. 4 & 5 - I would go for providing a default behavior (without using any extra arguments) being identical to other pub/sub solution semantic concerning bubbling.
Are there any real use case of scoping down?
6 - I already received a backdoor integration request from the NSA ;)
Really happy about the discussion on this thread.
Following this discussion I have documented explicitly the available subscription models.
Default behavior is the classic pub/sub behavior.
It is also possible to listen to all events occuring higher in the topic path by using a specific http param ?sub=wide
when subscribing.
Interesting design decision .. I would have said that if one listens for /topics/animals one gets all animal related messages (incl. furry) but if one listens on /topics/animals/furry then one just gets those and not messages from /topics/animals
Thoughts?