protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            while (true)
            {
                foreach (var name in ObjectMother.Names)
                {
                    var correlationId     = Guid.NewGuid();
                    var actorProxyFactory =
                        new ActorProxyFactory(
                            callbackClient =>
                            FabricTransportActorRemotingHelpers.CreateServiceRemotingClientFactory(typeof(IPersonActorService), callbackClient, _communicationLogger,
                                                                                                   correlationId.ToString()));
                    //var actorProxyFactory = new ActorProxyFactory();
                    await actorProxyFactory.RunInContext(async factory =>
                    {
                        var title = ObjectMother.Titles[Environment.TickCount % ObjectMother.Titles.Length];

                        var proxy = actorProxyFactory.CreateActorProxy <IPersonActor>(new ActorId(name));
                        await proxy.SetTitleAsync(title, cancellationToken);

                        _logger.PersonGenerated(name, title);
                    },
                                                         _communicationLogger,
                                                         new CustomServiceRequestHeader(new Dictionary <string, string>()
                    {
                        { "name", "service itself" }, { "correlation-id", Guid.NewGuid().ToString() }
                    })
                                                         );

                    await Task.Delay(200000, cancellationToken);
                }
            }
        }
コード例 #2
0
        private IServiceRemotingClientFactory CreateServiceRemotingClientFactory(IServiceRemotingCallbackClient serviceRemotingCallbackClient, Type serviceInterfaceType, Type actorInterfaceType)
        {
            var serviceMethodDispatcher = base.GetOrDiscoverServiceMethodDispatcher(serviceInterfaceType);
            var actorMethodDispatcher   = GetOrDiscoverActorMethodDispatcher(actorInterfaceType);

            var interfaceType = actorInterfaceType ?? serviceInterfaceType;

            return(FabricTransportActorRemotingHelpers.CreateServiceRemotingClientFactory(
                       interfaceType,
                       serviceRemotingCallbackClient,
                       Logger,
                       ServiceRequestContext.Current?[ServiceRequestContextKeys.CorrelationId],
                       serviceMethodDispatcher,
                       actorMethodDispatcher));
        }
 private IServiceRemotingClientFactory CreateServiceRemotingClientFactory(IServiceRemotingCallbackClient serviceRemotingCallbackClient, Type actorInterfaceType)
 {
     return(FabricTransportActorRemotingHelpers.CreateServiceRemotingClientFactory(actorInterfaceType, serviceRemotingCallbackClient, Logger,
                                                                                   ServiceRequestContext.Current.CorrelationId));
 }