-
Notifications
You must be signed in to change notification settings - Fork 56
Result of subscribing to topic inaccessible when calling makeSubscription causing race condition #44
Comments
Hmm, that's some interesting points (that also show how difficult it is how to build a robust implementation of such a system). I think you are even pointing out multiple issues here:
|
Yes I meant a data race, I didn't mean to imply that there was a threading As for the changing the API or a potential fix, I agree I don't really like
|
Currently when you subscribe to a topic via makeSubscription, there's no way to know if/when the subscription succeeded, as the observable returned only provides the PubSubData when something is published to the topic.
I have the following scenario where I create a "dynamic" topic, Ie. the topic has some filter information associated with it. So basically I subscribe to the topic from my client with a generated topic name, then I call a procedure registered on the router supplying the topic URI and my filter information, allowing the publisher to start publishing data to my dynamic topic. This results in a race though. Consider this:
Now the published event is received by the subscribed client, but can dropped because subscription on client has not been fully created, due to the result of the initial subscription request being processed on another thread in WampClient (scheduler) where it adds it to the map. The event can be received before or after the subscribe result is processed, resulting in a race.
If I knew when the subscription actually we finished successfully, I could then wait to call "createSubscription" to start getting data, but I can't because I don't know anything about the status of the subscription internally.
I also don't really have a good suggestion about how to fix this either.
The text was updated successfully, but these errors were encountered: