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 FromExceptionTest()
        {
            // Arrange
            var       expectedLength = 944;
            Exception exception      = new Exception("Test Exception");

            // Act
            var result = RemoteExceptionInformation.FromException(exception);

            // Assert
            Assert.Equal(expectedLength, result.Data.Length);
        }
示例#3
0
 public async Task <byte[]> RequestResponseAsync(ServiceRemotingMessageHeaders headers, byte[] requestBody)
 {
     try
     {
         return(await this.messageHandler.RequestResponseAsync(
                    this.requestContext,
                    headers,
                    requestBody));
     }
     catch (Exception e)
     {
         throw new FaultException <RemoteExceptionInformation>(RemoteExceptionInformation.FromException(e));
     }
 }
示例#4
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));
            }
        }