Exemplo n.º 1
0
        internal IRabbitQueue DeclareQueueInternal(bool nowait, string name, QueueOptions options)
        {
            Argument.NotNull(name, "name");
            if (nowait && name == String.Empty)
            {
                throw new ArgumentException("Auto gen queues cannot be declared with no-wait");
            }

            EnsureNotDisposed();

            options = options ?? QueueOptions.Default;

            var serializer = options.Serializer ?? _defaultSerializer;

            lock (_model)
            {
                if (nowait)
                {
                    _model.QueueDeclareNoWait(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
                    return(new RabbitQueue(_model, serializer, new QueueDeclareOk(name, 0, 0), options));
                }

                var result = _model.QueueDeclare(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
                return(new RabbitQueue(_model, serializer, result, options));
            }
        }
Exemplo n.º 2
0
        internal IRabbitQueue DeclareQueueInternal(bool nowait, string name, QueueOptions options)
        {
            Argument.NotNull(name, "name");
            if (nowait && name == String.Empty)
            {
                throw new ArgumentException("Auto gen queues cannot be declared with no-wait");
            }

            options = options ?? QueueOptions.Default;

            var serializer = options.Serializer ?? _defaultSerializer;

            lock (_model)
            {
                QueueDeclareOk result;

                if (nowait)
                {
                    _model.QueueDeclareNoWait(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
                    result = new QueueDeclareOk(name, 0, 0);
                }
                else
                {
                    result = _model.QueueDeclare(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
                }

                if (!this._isDefaultExchange)
                {
                    // binds it to "this" exchange
                    _model.QueueBind(result.QueueName, this.Name, "");
                }

                return(new RabbitQueue(_model, serializer, result, options));
            }
        }
Exemplo n.º 3
0
		public RabbitQueue(IModel model, 
						   IRabbitSerializer serializer,
						   QueueDeclareOk result, 
						   QueueOptions queueOptions)
		{
			_model = model;
			_defaultSerializer = serializer ?? queueOptions.Serializer;
			_queueOptions = queueOptions;

			this.Name = result.QueueName;
			this.ConsumerCount = result.ConsumerCount;
			this.MessageCount = result.MessageCount;
		}
Exemplo n.º 4
0
        public RabbitQueue(IModel model,
                           IRabbitSerializer serializer,
                           QueueDeclareOk result,
                           QueueOptions queueOptions)
        {
            _model             = model;
            _defaultSerializer = serializer ?? queueOptions.Serializer;
            _queueOptions      = queueOptions;

            this.Name          = result.QueueName;
            this.ConsumerCount = result.ConsumerCount;
            this.MessageCount  = result.MessageCount;
        }
Exemplo n.º 5
0
 public IRabbitQueue DeclareQueueNoWait(string name, QueueOptions options)
 {
     return(DeclareQueueInternal(true, name, options));
 }
Exemplo n.º 6
0
 public IRabbitQueue DeclareQueue(string name, QueueOptions options)
 {
     return(DeclareQueueInternal(false, name, options));
 }
Exemplo n.º 7
0
 protected bool Equals(QueueOptions other)
 {
     return(Durable == other.Durable && Exclusive == other.Exclusive && AutoDelete == other.AutoDelete);
 }
Exemplo n.º 8
0
		public IRabbitQueue DeclareQueueNoWait(string name, QueueOptions options)
		{
			return this.DeclareQueueInternal(true, name, options);
		}
Exemplo n.º 9
0
		public IRabbitQueue	DeclareQueue(string	name, QueueOptions options)
		{
			return this.DeclareQueueInternal(false, name, options);
		}
Exemplo n.º 10
0
		internal IRabbitQueue DeclareQueueInternal(bool nowait, string name, QueueOptions options)
		{
			Argument.NotNull(name, "name");
			if (nowait && name == String.Empty) throw new ArgumentException("Auto gen queues cannot be declared with no-wait");

			EnsureNotDisposed();

			options = options ?? QueueOptions.Default;

			var serializer = options.Serializer ?? _defaultSerializer;

			lock (_model)
			{
				if (nowait)
				{
					_model.QueueDeclareNoWait(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
					return new RabbitQueue(_model, serializer, new QueueDeclareOk(name, 0, 0), options);
				}

				var result = _model.QueueDeclare(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
				return new RabbitQueue(_model, serializer, result, options);
			}
		}
Exemplo n.º 11
0
		internal IRabbitQueue DeclareQueueInternal(bool nowait, string name, QueueOptions options)
		{
			Argument.NotNullOrEmpty(name, "name");

			EnsureNotDisposed();

			options = options ?? QueueOptions.Default;

			var serializer = options.Serializer ?? _defaultSerializer;

			lock (_model)
			{
				if (nowait)
				{
					_model.QueueDeclareNoWait(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
					return new RabbitQueue(_model, serializer, new QueueDeclareOk(name, 0, 0), options);
				}

				var result = _model.QueueDeclare(name, options.Durable, options.Exclusive, options.AutoDelete, options.Arguments);
				return new RabbitQueue(_model, serializer, result, options);
			}
		}