示例#1
0
        public static PublicationAddress ToPublicationAddress(this Uri uri, RabbitChannelGroupConfiguration config)
        {
            if (uri == ChannelEnvelope.LoopbackAddress)
            {
                return(new PublicationAddress(ExchangeType.Direct, string.Empty, config.InputQueue));
            }

            if (uri == ChannelEnvelope.DeadLetterAddress)
            {
                return(config.DeadLetterExchange);
            }

            if (uri == ChannelEnvelope.UnhandledMessageAddress)
            {
                return(config.UnhandledMessageExchange);
            }

            if (uri == ChannelEnvelope.UnroutableMessageAddress)
            {
                return(config.UnroutableMessageExchange);
            }

            var address = PublicationAddress.Parse(uri.ToString());

            return(address.ExchangeName.NormalizeName() == "default"
                                ? new PublicationAddress(ExchangeType.Direct, string.Empty, address.RoutingKey) : address);
        }
示例#2
0
 public Subscription(IModel channel, RabbitChannelGroupConfiguration config) : this()
 {
     this.channel      = channel;
     this.subscription = new RabbitMQ.Client.MessagePatterns.Subscription(
         channel,
         config.InputQueue,
         config.TransactionType == RabbitTransactionType.None);
 }
示例#3
0
		public Subscription(IModel channel, RabbitChannelGroupConfiguration config) : this()
		{
			this.channel = channel;
			this.subscription = new RabbitMQ.Client.MessagePatterns.Subscription(
				channel,
				config.InputQueue,
				config.TransactionType == RabbitTransactionType.None);
		}
示例#4
0
		protected virtual IMessagingChannel EstablishChannel(RabbitChannelGroupConfiguration config)
		{
			this.ThrowWhenDisposed();

			var channel = this.EstablishChannel();
			return new RabbitChannel(
				channel,
				config,
				() => new RabbitSubscription(new Subscription(channel, config)));
		}
示例#5
0
		public virtual RabbitWireup AddChannelGroup(Action<RabbitChannelGroupConfiguration> callback)
		{
			if (callback == null)
				throw new ArgumentNullException("callback");

			var config = new RabbitChannelGroupConfiguration();
			callback(config);
			this.configurations.Add(config);

			return this;
		}
示例#6
0
        protected virtual IMessagingChannel EstablishChannel(RabbitChannelGroupConfiguration config)
        {
            this.ThrowWhenDisposed();

            var channel = this.EstablishChannel();

            return(new RabbitChannel(
                       channel,
                       this,
                       config,
                       () => new RabbitSubscription(new Subscription(channel, config))));
        }
示例#7
0
        public virtual RabbitWireup AddChannelGroup(Action <RabbitChannelGroupConfiguration> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            var config = new RabbitChannelGroupConfiguration();

            callback(config);
            this.configurations.Add(config);

            return(this);
        }
示例#8
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);
        }
示例#9
0
        protected virtual IMessagingChannel EstablishChannel(RabbitChannelGroupConfiguration config)
        {
            this.ThrowWhenDisposed();

            var channel = this.EstablishChannel();

            try
            {
                return(new RabbitChannel(
                           channel,
                           this.connection,
                           this,
                           config,
                           () => new RabbitSubscription(new Subscription(channel, config))));
            }
            catch (Exception e)
            {
                // the RabbitChannel instance performs a few TCP-level operations, e.g. TxSelect, BasicQos, etc.
                this.Close(channel, ConnectionState.Closed, e);
                return(null);
            }
        }
示例#10
0
		protected virtual IMessagingChannel EstablishChannel(RabbitChannelGroupConfiguration config)
		{
			this.ThrowWhenDisposed();

			var channel = this.EstablishChannel();

			try
			{
				return new RabbitChannel(
					channel,
					this.connection,
					this,
					config,
					() => new RabbitSubscription(new Subscription(channel, config)));
			}
			catch (Exception e)
			{
				// the RabbitChannel instance performs a few TCP-level operations, e.g. TxSelect, BasicQos, etc.
				this.Close(channel, ConnectionState.Closed, e);
				return null;
			}
		}
		public RabbitMessageAdapter(RabbitChannelGroupConfiguration configuration) : this()
		{
			this.configuration = configuration;
		}
示例#12
0
		public RabbitChannel(
			IModel channel,
			RabbitChannelGroupConfiguration configuration,
			Func<RabbitSubscription> subscriptionFactory) : this()
		{
			this.channel = channel;
			this.CurrentConfiguration = this.configuration = configuration;
			this.adapter = configuration.MessageAdapter;
			this.transactionType = configuration.TransactionType;
			this.subscriptionFactory = subscriptionFactory;
			this.CurrentResolver = configuration.DependencyResolver;

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

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

			Log.Debug("Buffering up to {0} message(s) on the channel.", this.configuration.ChannelBuffer);
			this.channel.BasicQos(0, (ushort)this.configuration.ChannelBuffer, false);
		}
		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);
		}
示例#14
0
 public RabbitMessageAdapter(RabbitChannelGroupConfiguration configuration) : this()
 {
     this.configuration = configuration;
 }