Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
        public void ProcessGrpcMessage(ServiceMessage2 message)
        {
            message.StampFour.Visited = true;
            message.StampFour.TimeNow = DateTime.UtcNow.Ticks;

            // convert protobuffer message to Datacontract and send it back to web proxy using http
            var m2 = new ServiceMessage
            {
                MessageId   = message.MessageId,
                MessageJson = message.MessageJson,
                SessionId   = message.SessionId,
                CommChannel = message.CommChannel,
                StampOne    = new Common.VisitStamp
                {
                    Visited = message.StampOne.Visited,
                    TimeNow = new DateTime(message.StampOne.TimeNow)
                },
                StampTwo = new Common.VisitStamp
                {
                    Visited = message.StampTwo.Visited,
                    TimeNow = new DateTime(message.StampTwo.TimeNow)
                },
                StampThree = new Common.VisitStamp
                {
                    Visited = message.StampThree.Visited,
                    TimeNow = new DateTime(message.StampThree.TimeNow)
                },
                StampFour = new Common.VisitStamp
                {
                    Visited = true,
                    TimeNow = DateTime.UtcNow,
                },
            };

            EndWithHttpPost(m2).GetAwaiter().GetResult();
        }
Beispiel #3
0
 public void ProcessGrpcMessage(ServiceMessage2 message)
 {
     message.StampThree.Visited = true;
     message.StampThree.TimeNow = DateTime.UtcNow.Ticks;
     GrpcClienHelper.SendMessage("Service4", message).GetAwaiter().GetResult();;
 }