public async Task <IActionResult> Start(string id) { try { var message = new ServiceMessage2(); message.CommChannel = "Grpc"; message.SessionId = id; message.MessageId = Guid.NewGuid().ToString(); message.StampOne = new Common.Grpc.VisitStamp(); message.StampOne.Visited = true; message.StampOne.TimeNow = DateTime.UtcNow.Ticks; // initiatilize all timestamps since we dont have defaults on the protobuf generated objects message.StampTwo = new Common.Grpc.VisitStamp(); message.StampTwo.Visited = false; message.StampTwo.TimeNow = 0; message.StampThree = new Common.Grpc.VisitStamp(); message.StampThree.Visited = false; message.StampThree.TimeNow = 0; message.StampFour = new Common.Grpc.VisitStamp(); message.StampFour.Visited = false; message.StampFour.TimeNow = 0; message.StampFive = new Common.Grpc.VisitStamp(); message.StampFive.Visited = false; message.StampFive.TimeNow = 0; /* * var resolver = ServicePartitionResolver.GetDefault(); * var serviceUri = new Uri(FabricRuntime.GetActivationContext().ApplicationName + "/Service2"); * var communicationFactory = new GrpcCommunicationClientFactory<Common.Grpc.GrpcMessageService.GrpcMessageServiceClient>(null, resolver); * var partitionList = await this._client.QueryManager.GetPartitionListAsync(serviceUri); * * foreach (var partition in partitionList) * { * long partitionKey = ((Int64RangePartitionInformation)partition.PartitionInformation).HighKey; * var partitionClient = new ServicePartitionClient<GrpcCommunicationClient<Common.Grpc.GrpcMessageService.GrpcMessageServiceClient>>(communicationFactory, serviceUri, new ServicePartitionKey(partitionKey), listenerName: "grpc"); * var reply = partitionClient.InvokeWithRetry((communicationClient) => communicationClient.Client.Send(message)); * } */ var response = await GrpcClienHelper.SendMessage("Service2", message); return(Ok(new { id = id })); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void ProcessGrpcMessage(ServiceMessage2 message) { message.StampThree.Visited = true; message.StampThree.TimeNow = DateTime.UtcNow.Ticks; GrpcClienHelper.SendMessage("Service4", message).GetAwaiter().GetResult();; }