Ejemplo n.º 1
0
		private MessageAck CreateAcker(MessageEnvelope newMsg)
		{
			var msgAcker = new MessageAck(() => { lock(_model) _model.BasicAck(newMsg.DeliveryTag, false); },
				(requeue) => { lock(_model) _model.BasicNack(newMsg.DeliveryTag, false, requeue); });
			
			return msgAcker;
		}
Ejemplo n.º 2
0
		public Subscription ConsumeRaw(Action<MessageEnvelope, IMessageAck> onReceived, 
									   ConsumerOptions options)
		{
			Argument.NotNull(onReceived, "onReceived");
			options = options ?? ConsumerOptions.Default;

			var consumer = CreateConsumer(options);

			consumer.Subscribe(new ActionAdapter(env =>
			{
				var msgAcker = new MessageAck(() => { lock(_model) _model.BasicAck(env.DeliveryTag, false); },
					(requeue) => { lock(_model) _model.BasicNack(env.DeliveryTag, false, requeue); });

				onReceived(env, msgAcker);
			}));

			lock(_model)
			{
				var consumerTag = _model.BasicConsume(this.Name, options.NoAck, consumer);

				return new Subscription(_model, consumerTag);
			}
		}
Ejemplo n.º 3
0
        public Subscription ConsumeRaw(Action <MessageEnvelope, IMessageAck> onReceived,
                                       ConsumerOptions options)
        {
            Argument.NotNull(onReceived, "onReceived");
            options = options ?? ConsumerOptions.Default;

            var consumer = CreateConsumer(options);

            consumer.Subscribe(new ActionAdapter(env =>
            {
                var msgAcker = new MessageAck(() => { lock (_model) _model.BasicAck(env.DeliveryTag, false); },
                                              (requeue) => { lock (_model) _model.BasicNack(env.DeliveryTag, false, requeue); });

                onReceived(env, msgAcker);
            }));

            lock (_model)
            {
                var consumerTag = _model.BasicConsume(this.Name, options.NoAck, consumer);

                return(new Subscription(_model, consumerTag));
            }
        }