Пример #1
0
 public DefaultChannelGroup(
     IChannelConnector connector, IChannelGroupConfiguration configuration, IWorkerGroup <IMessagingChannel> workers)
 {
     this.connector     = connector;
     this.configuration = configuration;
     this.workers       = workers;
 }
		public DependencyResolverConnector(IChannelConnector connector)
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			this.connector = connector;
		}
        public DependencyResolverConnector(IChannelConnector connector)
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }

            this.connector = connector;
        }
Пример #4
0
		public AuditConnector(IChannelConnector connector, Func<IMessagingChannel, IEnumerable<IMessageAuditor>> auditorFactory)
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			if (auditorFactory == null)
				throw new ArgumentNullException("auditorFactory");

			this.connector = connector;
			this.auditorFactory = auditorFactory;
		}
		public SynchronousChannelGroup(IChannelConnector connector, IChannelGroupConfiguration configuration)
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			if (configuration == null)
				throw new ArgumentNullException("configuration");

			this.connector = connector;
			this.configuration = configuration;
		}
Пример #6
0
		public virtual MessagingWireup AddConnector(IChannelConnector channelConnector)
		{
			if (channelConnector == null)
				throw new ArgumentNullException("channelConnector");

			Log.Debug("Adding channel connector of type '{0}'.", channelConnector.GetType());

			if (channelConnector.GetType() != typeof(DependencyResolverConnector))
				channelConnector = new DependencyResolverConnector(channelConnector);

			this.connectors.Add(channelConnector);
			return this;
		}
		public virtual IChannelGroup Build(IChannelConnector connector, IChannelGroupConfiguration configuration)
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			if (configuration == null)
				throw new ArgumentNullException("configuration");

			Log.Debug("Building channel group named '{0}'.", configuration.GroupName);

			var workers = new TaskWorkerGroup<IMessagingChannel>(configuration.MinWorkers, configuration.MaxWorkers);
			return new DefaultChannelGroup(connector, configuration, workers);
		}
Пример #8
0
        public AuditConnector(IChannelConnector connector, Func <IMessagingChannel, IEnumerable <IMessageAuditor> > auditorFactory)
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }

            if (auditorFactory == null)
            {
                throw new ArgumentNullException("auditorFactory");
            }

            this.connector      = connector;
            this.auditorFactory = auditorFactory;
        }
        public SynchronousChannelGroup(IChannelConnector connector, IChannelGroupConfiguration configuration)
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            this.connector     = connector;
            this.configuration = configuration;
        }
        public PooledDispatchConnector(IChannelConnector connector) : this()
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }

            foreach (var config in connector.ChannelGroups.Where(x => x.DispatchOnly && x.Synchronous))
            {
                Log.Info("Channels for group '{0}' will be pooled.", config.GroupName);
                this.available[config.GroupName] = new ConcurrentBag <IMessagingChannel>();
            }

            Log.Debug("{0} pooled channel groups configured.", this.available.Values.Count);
            this.connector = connector;
        }
Пример #11
0
        public virtual MessagingWireup AddConnector(IChannelConnector channelConnector)
        {
            if (channelConnector == null)
            {
                throw new ArgumentNullException("channelConnector");
            }

            Log.Debug("Adding channel connector of type '{0}'.", channelConnector.GetType());

            if (channelConnector.GetType() != typeof(PooledDispatchConnector))
            {
                channelConnector = new PooledDispatchConnector(channelConnector);
            }

            if (channelConnector.GetType() != typeof(DependencyResolverConnector))
            {
                channelConnector = new DependencyResolverConnector(channelConnector);
            }

            this.connectors.Add(channelConnector);
            return(this);
        }
Пример #12
0
        public RabbitChannel(
            IModel channel,
            IConnection connection,
            IChannelConnector connector,
            RabbitChannelGroupConfiguration configuration,
            Func <RabbitSubscription> subscriptionFactory) : this()
        {
            this.channel              = channel;
            this.connection           = connection;
            this.connector            = connector;
            this.CurrentConfiguration = this.configuration = configuration;
            this.adapter              = configuration.MessageAdapter;
            this.transactionType      = configuration.TransactionType;
            this.subscriptionFactory  = subscriptionFactory;
            this.CurrentResolver      = configuration.DependencyResolver;
            this.identifier           = Interlocked.Increment(ref counter);

            this.CurrentTransaction = new RabbitTransaction(this, this.transactionType);
            if (this.transactionType == RabbitTransactionType.Full)
            {
                Log.Debug("Marking channel {0} as transactional.", this.identifier);
                this.channel.TxSelect();
            }

            if (this.configuration.ChannelBuffer <= 0 || this.configuration.DispatchOnly)
            {
                return;
            }

            var buffer = this.transactionType == RabbitTransactionType.None ? long.MaxValue : this.configuration.ChannelBuffer;

            Log.Debug("Buffering up to {0} message(s) on the channel {1}.", buffer, this.identifier);
            if (this.configuration.TransactionType == RabbitTransactionType.None)
            {
                return;
            }

            this.channel.BasicQos(0, (ushort)this.configuration.ChannelBuffer, false);
        }
        public virtual IChannelGroup Build(IChannelConnector connector, IChannelGroupConfiguration configuration)
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }

            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (configuration.Synchronous)
            {
                Log.Debug("Building a synchronous channel group named '{0}'.", configuration.GroupName);
                return(new SynchronousChannelGroup(connector, configuration));
            }

            Log.Debug("Building an asynchronous channel group named '{0}'.", configuration.GroupName);
            var workers = new TaskWorkerGroup <IMessagingChannel>(
                configuration.MinWorkers, configuration.MaxWorkers, configuration.MaxDispatchBuffer);

            return(new DefaultChannelGroup(connector, configuration, workers));
        }
 protected static void Build(IChannelConnector wrapped)
 {
     connector = new DependencyResolverConnector(wrapped);
 }
		public DefaultChannelGroup(
			IChannelConnector connector, IChannelGroupConfiguration configuration, IWorkerGroup<IMessagingChannel> workers)
		{
			this.connector = connector;
			this.configuration = configuration;
			this.workers = workers;
		}
		protected static void Build(IChannelConnector wrapped)
		{
			connector = new DependencyResolverConnector(wrapped);
		}
		public RabbitChannel(
			IModel channel,
			IChannelConnector connector,
			RabbitChannelGroupConfiguration configuration,
			Func<RabbitSubscription> subscriptionFactory) : this()
		{
			this.channel = channel;
			this.connector = connector;
			this.CurrentConfiguration = this.configuration = configuration;
			this.adapter = configuration.MessageAdapter;
			this.transactionType = configuration.TransactionType;
			this.subscriptionFactory = subscriptionFactory;
			this.CurrentResolver = configuration.DependencyResolver;
			this.identifier = Interlocked.Increment(ref counter);

			this.CurrentTransaction = new RabbitTransaction(this, this.transactionType);
			if (this.transactionType == RabbitTransactionType.Full)
			{
				Log.Debug("Marking channel {0} as transactional.", this.identifier);
				this.channel.TxSelect();
			}

			if (this.configuration.ChannelBuffer <= 0 || this.configuration.DispatchOnly)
				return;

			var buffer = this.transactionType == RabbitTransactionType.None ? long.MaxValue : this.configuration.ChannelBuffer;
			Log.Debug("Buffering up to {0} message(s) on the channel {1}.", buffer, this.identifier);
			if (this.configuration.TransactionType == RabbitTransactionType.None)
				return;

			this.channel.BasicQos(0, (ushort)this.configuration.ChannelBuffer, false);
		}
		public PooledDispatchConnector(IChannelConnector connector) : this()
		{
			if (connector == null)
				throw new ArgumentNullException("connector");

			foreach (var config in connector.ChannelGroups.Where(x => x.DispatchOnly && x.Synchronous))
			{
				Log.Info("Channels for group '{0}' will be pooled.", config.GroupName);
				this.available[config.GroupName] = new ConcurrentBag<IMessagingChannel>();
			}

			Log.Debug("{0} pooled channel groups configured.", this.available.Values.Count);
			this.connector = connector;
		}