+con #3551 Buffer messages in cluster client

* Stash when establishing connection to receptionist
This commit is contained in:
Patrik Nordwall 2013-09-09 14:56:16 +02:00
parent beba5d9f76
commit 09e3953c9f
4 changed files with 38 additions and 12 deletions

View file

@ -103,11 +103,8 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
"communicate to actor on any node in cluster" in within(10 seconds) {
runOn(client) {
val c = system.actorOf(ClusterClient.props(initialContacts))
awaitAssert {
c ! ClusterClient.Send("/user/testService", "hello", localAffinity = true)
expectMsg(1 second, "ack")
}
c ! ClusterClient.Send("/user/testService", "hello", localAffinity = true)
expectMsg("ack")
}
runOn(fourth) {
expectMsg("hello")
@ -133,6 +130,11 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
}
//#server
runOn(host1, host2, host3) {
awaitCount(4)
}
enterBarrier("services-replicated")
//#client
runOn(client) {
val c = system.actorOf(ClusterClient.props(initialContacts))
@ -141,6 +143,11 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
}
//#client
runOn(client) {
// note that "hi" was sent to 2 "serviceB"
receiveN(3).toSet must be(Set("hello", "hi"))
}
{ //not used, only demo
//#initialContacts
val initialContacts = Set(
@ -165,10 +172,8 @@ class ClusterClientSpec extends MultiNodeSpec(ClusterClientSpec) with STMultiNod
runOn(client) {
val c = system.actorOf(ClusterClient.props(initialContacts))
awaitAssert {
c ! ClusterClient.Send("/user/service2", "bonjour", localAffinity = true)
expectMsg(1 second, "ack")
}
c ! ClusterClient.Send("/user/service2", "bonjour", localAffinity = true)
expectMsg("ack")
val lastSenderAddress = lastSender.path.address
val receptionistRoleName = roleName(lastSenderAddress) match {
case Some(r) r