public async Task <FabricTransportReplyMessage> RequestResponseAsync(
            FabricTransportRequestContext requestContext, byte[] headers, byte[] requestBody)
        {
            // We have Cancellation Token for Remoting layer , hence timeout is not used here.
            ServiceRemotingMessageHeaders messageHeaders = null;

            try
            {
                messageHeaders = ServiceRemotingMessageHeaders.Deserialize(this.serializer, headers);
            }
            catch (Exception e)
            {
                //This can only happen if there is issue in our product code like Message Corruption or changing headers format.
                ReleaseAssert.Failfast("DeSerialization failed  for RemotingMessageHeaders with reason {0} for the headers with length {1}", e, headers.Length);
            }

            var context = new FabricTransportServiceRemotingRequestContext(requestContext);

            byte[] replybody;
            try
            {
                replybody = await this.messageHandler.RequestResponseAsync(context, messageHeaders, requestBody);

                return(new FabricTransportReplyMessage(false, replybody));
            }
            catch (Exception e)
            {
                ServiceTrace.Source.WriteInfo("FabricTransportCommunicationHandler", "Exception While dispatching {0}",
                                              e);
                var remoteExceptionInformation = RemoteExceptionInformation.FromException(e);
                replybody = remoteExceptionInformation.Data;
                return(new FabricTransportReplyMessage(true, replybody));
            }
        }
        public void HandleOneWay(FabricTransportRequestContext requestContext, byte[] headers, byte[] requestBody)
        {
            var messageHeaders = ServiceRemotingMessageHeaders.Deserialize(this.serializer, headers);
            var context        = new FabricTransportServiceRemotingRequestContext(requestContext);

            this.messageHandler.HandleOneWay(context, messageHeaders, requestBody);
        }
Ejemplo n.º 3
0
 public FabricTransportServiceRemotingRequestContext(FabricTransportRequestContext requestContext,
                                                     ServiceRemotingMessageSerializersManager serializersManager)
 {
     this.requestContext     = requestContext;
     this.serializersManager = serializersManager;
     this.id = requestContext.ClientId;
 }
Ejemplo n.º 4
0
        public async Task <FabricTransportMessage> RequestResponseAsync(FabricTransportRequestContext requestContext,
                                                                        FabricTransportMessage fabricTransportMessage)
        {
            if (null != this.serviceRemotingPerformanceCounterProvider.serviceOutstandingRequestsCounterWriter)
            {
                this.serviceRemotingPerformanceCounterProvider.serviceOutstandingRequestsCounterWriter
                .UpdateCounterValue(1);
            }
            var requestStopWatch = Stopwatch.StartNew();
            var requestResponseSerializationStopwatch = Stopwatch.StartNew();

            try
            {
                var remotingRequestMessage = this.CreateRemotingRequestMessage(fabricTransportMessage, requestResponseSerializationStopwatch
                                                                               );

                var retval = await
                             this.remotingMessageHandler.HandleRequestResponseAsync(
                    new FabricTransportServiceRemotingRequestContext(requestContext, this.serializersManager),
                    remotingRequestMessage);

                return(this.CreateFabricTransportMessage(retval, remotingRequestMessage.GetHeader().InterfaceId, requestResponseSerializationStopwatch));
            }
            catch (Exception ex)
            {
                ServiceTrace.Source.WriteInfo("FabricTransportMessageHandler", "Remote Exception occured {0}", ex);
                return(this.CreateFabricTransportExceptionMessage(ex));
            }
            finally
            {
                fabricTransportMessage.Dispose();
                if (null != this.serviceRemotingPerformanceCounterProvider.serviceOutstandingRequestsCounterWriter)
                {
                    this.serviceRemotingPerformanceCounterProvider.serviceOutstandingRequestsCounterWriter
                    .UpdateCounterValue(-1);
                }

                if (null != this.serviceRemotingPerformanceCounterProvider.serviceRequestProcessingTimeCounterWriter)
                {
                    this.serviceRemotingPerformanceCounterProvider.serviceRequestProcessingTimeCounterWriter
                    .UpdateCounterValue(
                        requestStopWatch.ElapsedMilliseconds);
                }
            }
        }
Ejemplo n.º 5
0
        public async Task <FabricTransportReplyMessage> RequestResponseAsync(
            FabricTransportRequestContext requestContext, byte[] headers, byte[] requestBody)
        {
            // We have Cancellation Token for Remoting layer , hence timeout is not used here.
            var messageHeaders = ServiceRemotingMessageHeaders.Deserialize(this.serializer, headers);
            var context        = new FabricTransportServiceRemotingRequestContext(requestContext);

            byte[] replybody;
            try
            {
                replybody = await this.messageHandler.RequestResponseAsync(context, messageHeaders, requestBody);

                return(new FabricTransportReplyMessage(false, replybody));
            }
            catch (Exception e)
            {
                ServiceTrace.Source.WriteInfo("FabricTransportCommunicationHandler", "Exception While dispatching {0}",
                                              e);
                var remoteExceptionInformation = RemoteExceptionInformation.FromException(e);
                replybody = remoteExceptionInformation.Data;
                return(new FabricTransportReplyMessage(true, replybody));
            }
        }
 public FabricTransportServiceRemotingRequestContext(FabricTransportRequestContext requestContext)
 {
     this.requestContext = requestContext;
     this.id             = requestContext.ClientId;
 }
Ejemplo n.º 7
0
 public void HandleOneWay(FabricTransportRequestContext requestContext,
                          FabricTransportMessage requesTransportMessage)
 {
     throw new NotImplementedException();
 }