FastTracks / TheAkkaWay

Akka Chinese Book / What should be included in it?
Apache License 2.0
19 stars 3 forks source link

pub/sub 这种,能否实现只让其中的一个sub 处理消息 #40

Open scalaoop opened 7 years ago

scalaoop commented 7 years ago

不想使用akka的clustering,N个sub,当pub发布消息后,仅让其中一个sub执行处理一次消息,其余的sub不会再重复去处理该消息. 该如何实现?

He-Pin commented 7 years ago

@scalaoop 您好,是可以的,这一点在官方文档中也有介绍,具体的来说就是PublishSend

This is a point-to-point mode where each message is delivered to one destination, but you still do not have to know where the destination is located.

http://doc.akka.io/docs/akka/current/scala/distributed-pub-sub.html#Send

使用的话,您需要自己维护一个注册表的哦。