/// <summary> /// This is the main entry point for your service instance. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { using (L.Operation()) { using (L.Context("p1".PairedWith("v1"), "p2".PairedWith("v2"))) { IStatefulSimulatorService proxy = CorrelatingServiceProxy.Create <IStatefulSimulatorService>( new Uri("fabric:/LogMagic.FabricTestApp/LogMagic.FabricApp.StatefulSimulator"), new ServicePartitionKey(0)); IActorSimulator actorProxy = CorrelatingActorProxy.Create <IActorSimulator>( ActorId.CreateRandom(), new Uri("fabric:/LogMagic.FabricTestApp/ActorSimulatorActorService")); await proxy.InvokeTest(); await actorProxy.SetCountAsync(5, cancellationToken); } } }
/// <summary> /// This is the main entry point for your service replica. /// This method executes when this replica of your service becomes primary and has write status. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service replica.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { var proxyFactory = new ServiceProxyFactory(c => new FabricTransportServiceRemotingClientFactory()); var proxyFactory2 = new ServiceProxyFactory(c => new CorrelatingFabricTransportServiceRemotingClientFactory <ISampleService>()); var proxyFactory3 = new ActorProxyFactory(); //ISampleService service = proxyFactory2.CreateServiceProxy<ISampleService>( // new Uri("fabric:/LogMagic.FabricTestApp2/LogMagic.FabricTestApp.StatelessSimulator")); ISampleService service = CorrelatingProxyFactory.CreateServiceProxy <ISampleService>( new Uri("fabric:/LogMagic.FabricTestApp2/LogMagic.FabricTestApp.StatelessSimulator"), raiseSummary: RaiseSummary, remoteServiceName: "StatelessSimulator"); IActorSimulator actor = CorrelatingProxyFactory.CreateActorProxy <IActorSimulator>(ActorId.CreateRandom()); //actor = proxyFactory3.CreateActorProxy<IActorSimulator>(ActorId.CreateRandom()); using (L.Context("param1", "value1")) { try { string hey = await service.PingSuccessAsync("hey"); await actor.SetCountAsync(5, cancellationToken); int count = await actor.GetCountAsync(cancellationToken); hey = await service.PingFailureAsync("fail"); } catch (Exception ex) { ex = null; } } }