public ProcessRequestAsyncResult(RoutingService service, Message message, AsyncCallback callback, object state) : base(callback, state) { this.allCompletedSync = true; this.service = service; this.messageRpc = new MessageRpc(message, OperationContext.Current, service.ChannelExtension.ImpersonationRequired); if (TD.RoutingServiceProcessingMessageIsEnabled()) { TD.RoutingServiceProcessingMessage(this.messageRpc.EventTraceActivity, this.messageRpc.UniqueID, message.Headers.Action, this.messageRpc.OperationContext.EndpointDispatcher.EndpointAddress.Uri.ToString(), messageRpc.Transaction != null ? "True" : "False"); } try { EndpointNameMessageFilter.Set(this.messageRpc.Message.Properties, service.ChannelExtension.EndpointName); this.messageRpc.RouteToSingleEndpoint <TContract>(this.service.RoutingConfig); } catch (MultipleFilterMatchesException matchesException) { // Wrap this exception with one that is more meaningful to users of RoutingService: throw FxTrace.Exception.AsError(new ConfigurationErrorsException(SR.ReqReplyMulticastNotSupported(this.messageRpc.OperationContext.Channel.LocalAddress), matchesException)); } while (this.StartProcessing()) { } }
public void AttachService(RoutingService service) { SessionChannels channelsToClose = null; lock (this.thisLock) { if (!this.hasSession) { RoutingConfiguration oldConfig = null; if (this.sessionService != null) { oldConfig = this.sessionService.RoutingConfig; } if (oldConfig != null && !object.ReferenceEquals(service.RoutingConfig, oldConfig)) { //The RoutingConfiguration has changed. We need to release any old channels that are cached. channelsToClose = this.sessionChannels; this.sessionChannels = null; } } else { Fx.Assert(this.sessionService == null, "There must only be one RoutingService created for a sessionful channel"); } this.sessionService = service; } if (channelsToClose != null) { channelsToClose.BeginClose(this.channel.OperationTimeout, closeChannelsCallback, channelsToClose); } }
public static IRoutingClient Create(RoutingEndpointTrait endpointTrait, RoutingService service, bool impersonating) { Type contractType = endpointTrait.RouterContract; IRoutingClient client; if (contractType == typeof(ISimplexDatagramRouter)) { client = new SimplexDatagramClient(endpointTrait, service.RoutingConfig, impersonating); } else if (contractType == typeof(IRequestReplyRouter)) { client = new RequestReplyClient(endpointTrait, service.RoutingConfig, impersonating); } else if (contractType == typeof(ISimplexSessionRouter)) { client = new SimplexSessionClient(endpointTrait, service.RoutingConfig, impersonating); } else //if (contractType == typeof(IDuplexSessionRouter)) { Fx.Assert(contractType == typeof(IDuplexSessionRouter), "Only one contract type remaining."); client = new DuplexSessionClient(service, endpointTrait, impersonating); } return(client); }
public ProcessMessagesAsyncResult(Message message, RoutingService service, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.service = service; this.channelExtension = service.ChannelExtension; this.timeoutHelper = new TimeoutHelper(timeout); this.timeoutHelper.RemainingTime(); //Start the timer if (message == null) { //Null message means end of session, time to close everything this.closeOutboundChannels = true; this.state = ProcessingState.ClosingChannels; } else { this.closeOutboundChannels = false; MessageRpc messageRpc = new MessageRpc(message, OperationContext.Current, this.channelExtension.ImpersonationRequired); if (TD.RoutingServiceProcessingMessageIsEnabled()) { TD.RoutingServiceProcessingMessage(messageRpc.EventTraceActivity, messageRpc.UniqueID, messageRpc.Message.Headers.Action, messageRpc.OperationContext.EndpointDispatcher.EndpointAddress.Uri.ToString(), (messageRpc.Transaction != null).ToString()); } EndpointNameMessageFilter.Set(messageRpc.Message.Properties, this.channelExtension.EndpointName); messageRpc.RouteToEndpoints <TContract>(this.service.RoutingConfig); this.service.SessionMessages.Add(messageRpc); this.sessionMessageIndex = this.service.SessionMessages.Count - 1; if (this.sessionMessageIndex == 0) { //First message, do initialization stuff this.state = ProcessingState.Initial; } else { this.state = ProcessingState.SendingSessionMessages; } } this.ProcessWhileSync(); }
public abstract IAsyncResult BeginShutdown(RoutingService service, TimeSpan timeout, AsyncCallback callback, object state);
internal IRoutingClient GetOrCreateClient <TContract>(RoutingEndpointTrait key, RoutingService service, bool impersonating) { IRoutingClient value; lock (this.sessions) { if (!this.sessions.TryGetValue(key, out value)) { //Create the client here value = ClientFactory.Create(key, service, impersonating); value.Faulted += ChannelFaulted; this.sessions[key] = value; sessionList.Add(value); } } return(value); }
public DuplexSessionClient(RoutingService service, RoutingEndpointTrait endpointTrait, bool impersonating) : base(endpointTrait, service.RoutingConfig, new DuplexCallbackProxy(service.ChannelExtension.ActivityID, endpointTrait.CallbackInstance), impersonating) { }