Ejemplo n.º 1
0
            protected override AmqpMessage CreateAmqpMessage()
            {
                AmqpMessage batchable = null;

                if (this.messages != null)
                {
                    foreach (BrokeredMessage message in this.messages)
                    {
                        if (batchable != null)
                        {
                            throw new NotSupportedException(SRClient.FeatureNotSupported("SendBatch"));
                        }
                        batchable           = MessageConverter.ClientGetMessage(message);
                        batchable.Batchable = base.Batchable;
                    }
                }
                return(batchable);
            }
Ejemplo n.º 2
0
            protected override bool ProcessMessage(IEnumerable <AmqpMessage> messages)
            {
                bool flag;
                List <BrokeredMessage> brokeredMessages = new List <BrokeredMessage>();

                using (IEnumerator <AmqpMessage> enumerator = messages.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        AmqpMessage     current = enumerator.Current;
                        BrokeredMessage empty   = MessageConverter.ClientGetMessage(current);
                        if (base.Receiver.Mode == ReceiveMode.PeekLock && empty.IsLockTokenSet && empty.LockedUntilUtc <= DateTime.UtcNow)
                        {
                            base.Link.ReleaseMessage(current);
                            if (base.Receiver.PrefetchCount == 0)
                            {
                                empty.Dispose();
                                flag = false;
                                return(flag);
                            }
                        }
                        if (base.Receiver.Mode == ReceiveMode.ReceiveAndDelete)
                        {
                            empty.LockToken = Guid.Empty;
                            base.Link.DisposeDelivery(current, true, AmqpConstants.AcceptedOutcome);
                        }
                        else if (base.Receiver.Mode == ReceiveMode.PeekLock && !empty.IsLockTokenSet)
                        {
                            empty.LockToken = Guid.NewGuid();
                            base.Receiver.lockedMessages.TryAdd(empty.LockToken, current.DeliveryTag);
                        }
                        brokeredMessages.Add(empty);
                    }
                    this.messages = brokeredMessages.ToArray();
                    return(true);
                }
                return(flag);
            }