public void A_loopback_registry() { Address = new Uri("loopback://localhost/"); ReceivedA = new Future <A>(); Registry = ActorRegistryFactory.New(x => { x.Remote(r => { r.ListenTo(Address); }); }); ActorId = Guid.NewGuid(); Actor = AnonymousActor.New(inbox => { inbox.Loop(loop => { loop.Receive <Message <A> >(message => { ReceivedA.Complete(message.Body); loop.Continue(); }); }); }); Registry.Register(ActorId, Actor); }
public void Run() { Trace.Listeners.Add(new ConsoleTraceListener()); const string remoteAddress = "rm://234.0.0.7:40001/"; Guid id = CombGuid.Generate(); ActorRegistry registry = ActorRegistryFactory.New(x => { x.Remote(r => r.ListenTo(remoteAddress)); }); ActorRef server = AnonymousActor.New(inbox => { inbox.Receive <Response <Hello> >(message => { Console.WriteLine("Hi!"); Console.WriteLine("Request ID: " + message.RequestId); }); }); registry.Register(id, server); var actorAddress = new ActorUrn(remoteAddress, id); registry.Select(actorAddress, actor => { actor.Send <Response <Hello> >(new ResponseImpl <Hello>(new Hello { MyNameIs = "Joe", }, "27")); }, () => {}); ThreadUtil.Sleep(5.Seconds()); registry.Shutdown(); }
public void Adding_an_actor_to_a_registry() { _auctionFactory = ActorFactory.Create(inbox => new Auction(inbox)); _auctionId = CombGuid.Generate(); ActorRef auction = _auctionFactory.GetActor(); ActorRegistry registry = ActorRegistryFactory.New(x => { //x.Remote(r => r.ListenTo("rm://234.0.0.7:40001")); }); registry.Register(_auctionId, auction); _response = new Future <Response <Bid> >(); AnonymousActor.New(inbox => { registry.Request <Bid>(new BidImpl(27.42m), header => { header.DestinationAddress = new ActorUrn(_auctionId); }, inbox) .Receive <Response <Bid> >(x => _response.Complete); }); _response.WaitUntilCompleted(5.Seconds()).ShouldBeTrue(); // need to proxy the channel with headers somehow... // untyped channel => channel mapper -> actor instance // DestinationAddress -> set by outbound channel proxy on message<> // SourceAddress -> set by outbound channel proxy when available (not likely) // ResponseAddress -> set by outbound channel for ResponseChannel on Request to map to channel // Id -> system assigned id // DestinationAddress = urn:actor:554FC958-4661-4FE9-94F5-21D190417BCC }