我有两个演员,一个是制作消息,另一个是以固定费率消费消息。
是否有可能让生产者受到消费者BoundedMailBox的限制? (背压)
我的制作人目前是定期安排的(发送一个勾选消息),有没有办法让消费者邮箱中的可用性安排好呢?
我正在使用fire并忘记样式(consumer.tell())因为我不需要响应。我应该使用不同的消息发送方法吗?
答案 0 :(得分:-1)
只需指定邮箱限制,如果邮箱已满,它似乎会阻止。 我自己没有试过这个,但是这个帖子中的人正在查看行为,并且发现只要邮箱达到极限,演员就会阻止。
请参阅此处进行讨论以及此类性质的更多测试。 https://groups.google.com/forum/?fromgroups=#!topic/akka-user/e0tebq5V4nM
从那个帖子:
object ProducerConsumer extends App {
implicit val system = ActorSystem("ProducerConsumer")
def waitFor(actor: ActorRef) {
Await.ready(gracefulStop(actor, 5.seconds), 5.seconds)
}
val consumers = system.actorOf(Props[Consumer].
withRouter(RoundRobinRouter(4)).
withDispatcher("consumer-dispatcher"), "consumer")
for (work <- generateWork)
consumers ! work
consumers ! PoisonPill
waitFor(consumers)
system.shutdown
}
application.conf:
consumer-dispatcher {
type = BalancingDispatcher
mailbox-capacity = 100
}