public virtual void Release(IMessagingChannel channel, int token) { if (channel == null) { throw new ArgumentNullException("channel"); } Log.Verbose("Trying to release the channel back to the pool for reuse."); bool value; if (!this.open.TryRemove(channel, out value)) { throw new InvalidOperationException("Cannot release a channel that didn't originate with this connector."); } if (this.currentToken >= 0 && this.currentToken == token && channel.Active) { this.available[channel.CurrentConfiguration.GroupName].Add(channel); } else { channel.TryDispose(); } }
public void BindMessagingChannel(IMessagingChannel <IProtocolGatewayMessage> channel) { IDeviceProxy deviceProxy = new DeviceProxy(channel, this.deviceListener.Identity, this.messageConverter, this.byteBufferConverter); this.deviceListener.BindDeviceProxy(deviceProxy); Events.BindMessageChannel(this.deviceListener.Identity); }
private IEnumerable <IMessageAuditor> GetAuditorsForChannel(IMessagingChannel channel) { return(new[] { new ApplicationInsightsMessageAuditor(channel) }); }
public void BindMessagingChannel(IMessagingChannel <IProtocolGatewayMessage> channel) { var sessionStateQuery = this.sessionStatePersistenceProvider.GetAsync(new AuthenticatedIdentity(this.deviceListener.Identity.Id)); IDeviceProxy deviceProxy = new DeviceProxy(channel, this.deviceListener.Identity, this.messageConverter, this.byteBufferConverter); this.deviceListener.BindDeviceProxy( deviceProxy, async() => { var sessionState = await sessionStateQuery; if (sessionState is SessionState registrationSessionState) { var subscriptions = SessionStateParser.GetDeviceSubscriptions(registrationSessionState.SubscriptionRegistrations, this.deviceListener.Identity.Id); foreach ((DeviceSubscription deviceSubscription, bool addSubscription) in subscriptions) { if (deviceSubscription == DeviceSubscription.Unknown) { continue; } if (addSubscription) { await this.deviceListener.AddSubscription(deviceSubscription); } else { await this.deviceListener.RemoveSubscription(deviceSubscription); } } } });
public PipelineDispatcherHook( IMessagingHost messagingHost) { _messagingHost = messagingHost; _channelGroup = _messagingHost.Initialize(); _messageChannel = _channelGroup.OpenChannel(); }
protected virtual ICollection<IMessageAuditor> ResolveAuditors(IMessagingChannel channel) { if (this.emptyFactory) return new IMessageAuditor[0]; return this.auditorFactory(channel).Where(x => x != null).ToArray(); }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel actual = null) { this.EnsureTransaction(); var context = new DefaultDispatchContext(actual ?? this); return(message == null ? context : context.WithMessage(message)); }
public void BindMessagingChannel(IMessagingChannel <IMessage> channel) { Contract.Requires(channel != null); Contract.Assert(this.messagingChannel == null); this.messagingChannel = channel; this.Receive(); }
protected virtual ICollection <IMessageAuditor> ResolveAuditors(IMessagingChannel channel) { if (this.emptyFactory) { return(new IMessageAuditor[0]); } return(this.auditorFactory(channel).Where(x => x != null).ToArray()); }
public DeviceProxy(IMessagingChannel <IProtocolGatewayMessage> channel, IIdentity identity, IMessageConverter <IProtocolGatewayMessage> messageConverter, IByteBufferConverter byteBufferConverter) { this.isActive = new AtomicBoolean(true); this.channel = Preconditions.CheckNotNull(channel, nameof(channel)); this.messageConverter = Preconditions.CheckNotNull(messageConverter, nameof(messageConverter)); this.Identity = Preconditions.CheckNotNull(identity, nameof(this.Identity)); this.byteBufferConverter = Preconditions.CheckNotNull(byteBufferConverter, nameof(byteBufferConverter)); }
public DefaultDispatchContext(IMessagingChannel channel) { this.Channel = this.channel = channel; this.dispatchTable = this.channel.CurrentConfiguration.DispatchTable; var config = channel.CurrentConfiguration; this.builder = config.MessageBuilder; this.returnAddress = config.ReturnAddress; }
public void BindMessagingChannel(IMessagingChannel channel) { Contract.Requires(channel != null); Contract.Assert(this.messagingChannel == null); this.messagingChannel = channel; this.lifetimeCancellation = new CancellationTokenSource(); this.Receive(); }
public DependencyResolverChannel(IMessagingChannel channel, IDependencyResolver resolver) { if (channel == null) throw new ArgumentNullException("channel"); if (resolver == null) throw new ArgumentNullException("resolver"); this.channel = channel; this.resolver = resolver; }
public DefaultChannelMessageDispatchContext(IMessagingChannel channel, ChannelMessage channelMessage) { if (channel == null) throw new ArgumentNullException("channel"); if (channelMessage == null) throw new ArgumentNullException("channelMessage"); this.channel = channel; this.channelMessage = channelMessage; }
public virtual void Teardown(IMessagingChannel channel, int token) { if (channel == null) throw new ArgumentNullException("channel"); if (!this.open.ContainsKey(channel)) throw new InvalidOperationException("Cannot tear down a channel that didn't originate with this connector."); if (this.FirstOneThrough(token, token + 1)) this.ClearAvailableChannels(); Log.Verbose("Tearing down channel."); channel.TryDispose(); }
public DependencyResolverChannel(IMessagingChannel channel, IDependencyResolver resolver) { if (channel == null) { throw new ArgumentNullException("channel"); } if (resolver == null) { throw new ArgumentNullException("resolver"); } this.channel = channel; this.resolver = resolver; }
public DefaultChannelMessageDispatchContext(IMessagingChannel channel, ChannelMessage channelMessage) { if (channel == null) { throw new ArgumentNullException("channel"); } if (channelMessage == null) { throw new ArgumentNullException("channelMessage"); } this.channel = channel; this.channelMessage = channelMessage; }
public PooledDispatchChannel(PooledDispatchConnector connector, IMessagingChannel channel, int token) { if (connector == null) throw new ArgumentNullException("connector"); if (channel == null) throw new ArgumentNullException("channel"); if (token < 0) throw new ArgumentException("The token greater than or equal to zero.", "token"); this.connector = connector; this.channel = channel; this.token = token; }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_messageChannel != null) { _messageChannel.Dispose(); _messageChannel = null; } if (_channelGroup != null) { _channelGroup.Dispose(); _channelGroup = null; } } }
public virtual void Release(IMessagingChannel channel, int token) { if (channel == null) throw new ArgumentNullException("channel"); Log.Verbose("Trying to release the channel back to the pool for reuse."); bool value; if (!this.open.TryRemove(channel, out value)) throw new InvalidOperationException("Cannot release a channel that didn't originate with this connector."); if (this.currentToken >= 0 && this.currentToken == token && channel.Active) this.available[channel.CurrentConfiguration.GroupName].Add(channel); else channel.TryDispose(); }
public void BindMessagingChannel(IMessagingChannel channel) { Contract.Requires(channel != null); Contract.Assert(this.messagingChannel == null); this.messagingChannel = channel; var closedCause = Volatile.Read(ref this.closedCause); if (closedCause != null) { channel.Close(closedCause); } foreach (var source in this.sources) { source.BindMessagingChannel(channel); } }
public AuditChannel(IMessagingChannel channel, ICollection <IMessageAuditor> auditors) { if (channel == null) { throw new ArgumentNullException("channel"); } if (auditors == null) { throw new ArgumentNullException("auditors"); } if (auditors.Count == 0) { throw new ArgumentException("At least one auditor must be provided.", "auditors"); } this.channel = channel; this.auditors = new List <IMessageAuditor>(auditors); }
public virtual void Teardown(IMessagingChannel channel, int token) { if (channel == null) { throw new ArgumentNullException("channel"); } if (!this.open.ContainsKey(channel)) { throw new InvalidOperationException("Cannot tear down a channel that didn't originate with this connector."); } if (this.FirstOneThrough(token, token + 1)) { this.ClearAvailableChannels(); } Log.Verbose("Tearing down channel."); channel.TryDispose(); }
public PooledDispatchChannel(PooledDispatchConnector connector, IMessagingChannel channel, int token) { if (connector == null) { throw new ArgumentNullException("connector"); } if (channel == null) { throw new ArgumentNullException("channel"); } if (token < 0) { throw new ArgumentException("The token greater than or equal to zero.", "token"); } this.connector = connector; this.channel = channel; this.token = token; }
public SubscriptionService( IOrchardServices orchardServices, IContentManager contentManager, IRepository<ThreadSubscriptionRecord> threadSubscriptionRepository, IRepository<UserPartRecord> userRepository, IUserPreferredCultureService userPreferredCultureService, ISubscriptionEmailTemplateService subscriptionEmailTemplateService, IMessagingChannel emailMessagingChannel, ISiteService siteService, IPostService postService ) { _orchardServices = orchardServices; _contentManager = contentManager; _threadSubscriptionRepository = threadSubscriptionRepository; _userRepository = userRepository; _userPreferredCultureService = userPreferredCultureService; _subscriptionEmailTemplateService = subscriptionEmailTemplateService; _emailMessageingChannel = emailMessagingChannel; _siteService = siteService; _postService = postService; }
public async void BindMessagingChannel(IMessagingChannel channel) { try { Contract.Requires(channel != null); Contract.Assert(this.messagingChannel == null); this.messagingChannel = channel; await this.bridge.DeviceClient.SetMethodHandlerAsync( this.methodName, (req, self) => { var handler = (MethodHandler)self; return(handler.dispatchCallback(req, handler)); }, this); } catch (Exception ex) { this.messagingChannel.Close(ex); } }
public ApplicationInsightsMessageAuditor(IMessagingChannel channel) { _channel = channel; _telemetryClient = new TelemetryClient(); }
protected static void Build(IMessagingChannel channel, ChannelMessage channelMessage) { dispatchContext = new DefaultChannelMessageDispatchContext(channel, channelMessage); }
protected static void Build(IMessagingChannel wrapped, IDependencyResolver resolver) { channel = new DependencyResolverChannel(wrapped, resolver); }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel actual = null) { Log.Debug("Preparing a dispatch"); return(this.CurrentContext.PrepareDispatch(message, actual ?? this)); }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel channel = null) { this.ThrowWhenDisposed(); return this.delivery.PrepareDispatch(message, channel); }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel actual = null) { this.EnsureTransaction(); var context = new DefaultDispatchContext(actual ?? this); return message == null ? context : context.WithMessage(message); }
public void BindMessagingChannel(IMessagingChannel <MessageWithFeedback> channel) { this.messagingChannel = channel; this.messagingChannel.CapabilitiesChanged += this.OnChannelCapabilitiesChanged; this.messagingClient.BindMessagingChannel(this); }
public SynchronousMessenger(IMessagingChannel channel) { this.channel = channel; }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel channel = null) { this.ThrowWhenDisposed(); return(this.delivery.PrepareDispatch(message, channel)); }
public IDispatchContext PrepareDispatch(object message = null, IMessagingChannel channel = null) { var context = new DefaultDispatchContext(channel ?? this); return(message == null ? context : context.WithMessage(message)); }
public void BindMessagingChannel(IMessagingChannel<IMessage> channel) { Contract.Requires(channel != null); Contract.Assert(this.messagingChannel == null); this.messagingChannel = channel; this.Receive(); }
public AuditChannel(IMessagingChannel channel, ICollection<IMessageAuditor> auditors) { if (channel == null) throw new ArgumentNullException("channel"); if (auditors == null) throw new ArgumentNullException("auditors"); if (auditors.Count == 0) throw new ArgumentException("At least one auditor must be provided.", "auditors"); this.channel = channel; this.auditors = auditors; }
public virtual IDispatchContext PrepareDispatch(object message = null, IMessagingChannel actual = null) { Log.Debug("Preparing a dispatch"); return this.CurrentContext.PrepareDispatch(message, actual ?? this); }
protected static void Build(IMessagingChannel channel, IDispatchTable dispatchTable) { dispatchContext = new DefaultDispatchContext(channel, dispatchTable); }
public void BindMessagingChannel(IMessagingChannel <MessageWithFeedback> channel) { this.messagingChannel = channel; this.messagingClient.BindMessagingChannel(this); }