public void ClusterClient_should_reestablish_connection_to_another_receptionist_when_server_is_shutdown()
{
ClusterClient_should_demonstrate_usage();
Within(TimeSpan.FromSeconds(30), () =>
{
RunOn(() =>
{
var service2 = Sys.ActorOf(Props.Create(() => new TestService(TestActor)), "service2");
ClusterClientReceptionist.Get(Sys).RegisterService(service2);
AwaitCount(8);
}, _first, _second, _third, _fourth);
EnterBarrier("service2-replicated");
RunOn(() =>
{
var c = Sys.ActorOf(Client.ClusterClient.Props(ClusterClientSettings.Create(Sys).WithInitialContacts(InitialContacts)), "client2");
c.Tell(new Client.ClusterClient.Send("/user/service2", "bonjour", localAffinity: true));
ExpectMsg("bonjour-ack");
var lastSenderAddress = LastSender.Path.Address;
var receptionistRoleName = RoleName(lastSenderAddress);
if (receptionistRoleName == null) throw new Exception("Unexpected missing role name: " + lastSenderAddress);
TestConductor.Exit(receptionistRoleName, 0).Wait();
_remainingServerRoleNames.Remove(receptionistRoleName);
Within(Remaining - TimeSpan.FromSeconds(3), () =>
{
AwaitAssert(() =>
{
c.Tell(new Client.ClusterClient.Send("/user/service2", "hi again", localAffinity: true));
ExpectMsg("hi again-ack", TimeSpan.FromSeconds(1));
});
});
Sys.Stop(c);
}, _client);
EnterBarrier("verified-3");
ReceiveWhile(TimeSpan.FromSeconds(2), msg =>
{
if (msg.Equals("hi again")) return msg;
else throw new Exception("unexpected message: " + msg);
});
EnterBarrier("after-4");
});
}