private FabricTransportMessage CreateFabricTransportMessage(IServiceRemotingResponseMessage retval, int interfaceId, Stopwatch stopwatch) { if (retval == null) { return(new FabricTransportMessage(null, null)); } var responseHeader = this.headerSerializer.SerializeResponseHeader(retval.GetHeader()); var fabricTransportRequestHeader = responseHeader != null ? new FabricTransportRequestHeader(responseHeader.GetSendBuffer(), responseHeader.Dispose) : new FabricTransportRequestHeader(new ArraySegment <byte>(), null); var responseSerializer = this.serializersManager.GetResponseBodySerializer(interfaceId); stopwatch.Restart(); var responseMsgBody = responseSerializer.Serialize(retval.GetBody()); if (this.serviceRemotingPerformanceCounterProvider.serviceResponseSerializationTimeCounterWriter != null) { this.serviceRemotingPerformanceCounterProvider.serviceResponseSerializationTimeCounterWriter .UpdateCounterValue(stopwatch.ElapsedMilliseconds); } var fabricTransportRequestBody = responseMsgBody != null ? new FabricTransportRequestBody(responseMsgBody.GetSendBuffers(), responseMsgBody.Dispose) : new FabricTransportRequestBody(new List <ArraySegment <byte> >(), null); var message = new FabricTransportMessage( fabricTransportRequestHeader, fabricTransportRequestBody); return(message); }
public async Task <FabricTransportMessage> RequestResponseAsync(FabricTransportMessage requestMessage, TimeSpan timeout) { try { return (await Utility.WrapNativeAsyncInvokeInMTA <FabricTransportMessage>( (callback) => this.BeginRequest(requestMessage, timeout, callback), this.EndRequest, CancellationToken.None, "RequestResponseAsync")); } catch (FabricCannotConnectException) { //TODO: Remove this check after Bug :1225032 gets resolved if (this.IsSecurityMismatch()) { throw new FabricConnectionDeniedException(SR.Error_ConnectionDenied); } throw; } catch (TimeoutException) { throw new TimeoutException(string.Format(CultureInfo.CurrentCulture, SR.ErrorServiceTooBusy)); } }
public void OneWayMessage(FabricTransportMessage message) { var headerSerializer = this.manager.GetHeaderSerializer(); var deserializerHeaders = headerSerializer.DeserializeRequestHeaders(new IncomingMessageHeader(message.GetHeader().GetRecievedStream())); var msgBodySerializer = this.manager.GetRequestBodySerializer(deserializerHeaders.InterfaceId); var deserializedMsgBody = msgBodySerializer.Deserialize(new IncomingMessageBody(message.GetBody().GetRecievedStream())); this.remotingCallbackClient.HandleOneWayMessage(new ServiceRemotingRequestMessage(deserializerHeaders, deserializedMsgBody)); }
private async Task <NativeFabricTransportMessage> RequestResponseAsync(string clientId, FabricTransportMessage fabricTransportMessage, TimeSpan timeout) { // We have Cancellation Token for Remoting layer , hence timeout is not used here. var context = new FabricTransportRequestContext(clientId, this.nativeConnectionHandler.GetCallBack); var replyMessage = await this.service.RequestResponseAsync(context, fabricTransportMessage); return(new NativeFabricTransportMessage(replyMessage)); }
private NativeCommon.IFabricAsyncOperationContext BeginRequest( FabricTransportMessage message, TimeSpan timeout, NativeCommon.IFabricAsyncOperationCallback callback) { var timeoutInMilliSeconds = Utility.ToMilliseconds(timeout, "timeout"); NativeFabricTransport.IFabricTransportMessage nativeFabricTransportMessage = new NativeFabricTransportMessage(message); return(this.nativeClient.BeginRequest(nativeFabricTransportMessage, timeoutInMilliSeconds, callback)); }
private FabricTransportMessage CreateFabricTransportExceptionMessage(Exception ex) { var header = new ServiceRemotingResponseMessageHeader(); header.AddHeader("HasRemoteException", new byte[0]); var serializedHeader = this.serializersManager.GetHeaderSerializer().SerializeResponseHeader(header); var serializedMsg = RemoteException.FromException(ex); var msg = new FabricTransportMessage( new FabricTransportRequestHeader(serializedHeader.GetSendBuffer(), serializedHeader.Dispose), new FabricTransportRequestBody(serializedMsg.Data, null)); return(msg); }
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); } } }
private IServiceRemotingRequestMessage CreateRemotingRequestMessage( FabricTransportMessage fabricTransportMessage, Stopwatch stopwatch) { var deSerializedHeader = this.headerSerializer.DeserializeRequestHeaders( new IncomingMessageHeader(fabricTransportMessage.GetHeader().GetRecievedStream())); var msgBodySerializer = this.serializersManager.GetRequestBodySerializer(deSerializedHeader.InterfaceId); stopwatch.Restart(); var deserializedMsg = msgBodySerializer.Deserialize( new IncomingMessageBody(fabricTransportMessage.GetBody().GetRecievedStream())); if (this.serviceRemotingPerformanceCounterProvider.serviceRequestDeserializationTimeCounterWriter != null) { this.serviceRemotingPerformanceCounterProvider.serviceRequestDeserializationTimeCounterWriter.UpdateCounterValue ( stopwatch.ElapsedMilliseconds); } return(new ServiceRemotingRequestMessage(deSerializedHeader, deserializedMsg)); }
public virtual void SendOneWay(FabricTransportMessage message) { NativeFabricTransport.IFabricTransportMessage nativeMessage = new NativeFabricTransportMessage(message); this.nativeClient.Send(nativeMessage); }
public void OneWayMessage(FabricTransportMessage requestBody) { NativeFabricTransport.IFabricTransportMessage message = new NativeFabricTransportMessage(requestBody); Utility.WrapNativeSyncInvokeInMTA(() => this.nativeClientConnection.Send(message), "NativeFabricClientConnection.SendMessage"); }
public void HandleOneWay(FabricTransportRequestContext requestContext, FabricTransportMessage requesTransportMessage) { throw new NotImplementedException(); }