Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub not support confirmed for Subscribe #32270

Open
jxnu-liguobin opened this issue Dec 27, 2023 · 2 comments
Open

pubsub not support confirmed for Subscribe #32270

jxnu-liguobin opened this issue Dec 27, 2023 · 2 comments

Comments

@jxnu-liguobin
Copy link
Contributor

https://github.com/jxnu-liguobin/akka/blob/b0384c646e2024a47056966553ca7d0137a911d1/akka-actor-typed/src/main/scala/akka/actor/typed/internal/pubsub/TopicImpl.scala#L119
In Subscribe,replyTo is not provided for confirming successful registration, but Register support it

    case Subscribe(subscriber) =>
      if (!localSubscribers.contains(subscriber)) {
        context.watchWith(subscriber, SubscriberTerminated(subscriber))
        localSubscribers = localSubscribers + subscriber
        if (localSubscribers.size == 1) {
          context.log.debug(
            "Local subscriber [{}] added, went from no subscribers to one, subscribing to receptionist",
            subscriber)
          // we went from no subscribers to one, register to the receptionist
          receptionist ! Receptionist.Register(topicServiceKey, context.self)
        } else {
          context.log.debug("Local subscriber [{}] added", subscriber)
        }
      } else {
        context.log.debug("Local subscriber [{}] already subscribed, ignoring Subscribe command")
      }
      this
  object Register {

    /**
     * Create a Register without Ack that the service was registered
     */
    def apply[T](key: ServiceKey[T], service: ActorRef[T]): Command =
      new ReceptionistMessages.Register[T](key, service, None)

    /**
     * Create a Register with an actor that will get an ack that the service was registered
     */
    def apply[T](key: ServiceKey[T], service: ActorRef[T], replyTo: ActorRef[Registered]): Command =
      new ReceptionistMessages.Register[T](key, service, Some(replyTo))
  }
@jxnu-liguobin jxnu-liguobin changed the title pubsub not confirmed for Subscribe pubsub not support confirmed for Subscribe Dec 27, 2023
@johanandren
Copy link
Member

I think that might give a false sense of security/delivery guarantees, because even if held off until the topic has registered and seen a reply from the receptionist, the receptionist on other nodes will not yet have seen that subscriber.

Can you describe a use case where you think the local subscription completing for some meaning of the word would be useful?

@jxnu-liguobin
Copy link
Contributor Author

I think that might give a false sense of security/delivery guarantees, because even if held off until the topic has registered and seen a reply from the receptionist, the receptionist on other nodes will not yet have seen that subscriber.

Can you describe a use case where you think the local subscription completing for some meaning of the word would be useful?

zio/zio-akka-cluster#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants