Esempio n. 1
0
        public void AcceptMessage(AmqpMessage message, bool batchable)
        {
            bool settled = this.Settings.SettleType != SettleMode.SettleOnDispose;

            this.AcceptMessage(message, settled, batchable);
        }
Esempio n. 2
0
 public void AcceptMessage(AmqpMessage message, bool settled, bool batchable)
 {
     this.DisposeMessage(message, AmqpConstants.AcceptedOutcome, settled, batchable);
 }
Esempio n. 3
0
 public void DisposeMessage(AmqpMessage message, DeliveryState deliveryState, bool settled, bool batchable)
 {
     this.receiver.DisposeMessage(message, deliveryState, settled, batchable);
 }
Esempio n. 4
0
 public Task <Outcome> SendMessageAsync(AmqpMessage message, ArraySegment <byte> deliveryTag, ArraySegment <byte> txnId, TimeSpan timeout)
 {
     return(this.sender.SendMessageAsync(message, deliveryTag, txnId, timeout));
 }
Esempio n. 5
0
 public void Start()
 {
     this.parent.sender.SendMessageNoWait(this.request, AmqpConstants.EmptyBinary, AmqpConstants.NullBinary);
     this.request = null;
 }
Esempio n. 6
0
 static void ReadHeaderSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.Header = ReadListSection <Header>(reader);
 }
Esempio n. 7
0
 static void ReadFooterSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.Footer = ReadMapSection <Footer>(reader);
 }
Esempio n. 8
0
 public IAsyncResult BeginRequest(AmqpMessage request, TimeSpan timeout, AsyncCallback callback, object state)
 {
     return(new RequestResponseAmqpLink.RequestAsyncResult(this, request, timeout, callback, state));
 }
Esempio n. 9
0
 static void ReadApplicationPropertiesSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.ApplicationProperties = ReadMapSection <ApplicationProperties>(reader);
 }
Esempio n. 10
0
 static void ReadAmqpSequenceSection(AmqpMessageReader reader, AmqpMessage message)
 {
     AmqpMessage.EnsureInitialized <List <AmqpSequence> >(ref reader.sequenceList);
     reader.sequenceList.Add(ReadListSection <AmqpSequence>(reader, true));
 }
Esempio n. 11
0
 static void ReadPropertiesSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.Properties = ReadListSection <Properties>(reader);
 }
Esempio n. 12
0
 static void ReadMessageAnnotationsSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.MessageAnnotations = ReadMapSection <MessageAnnotations>(reader);
 }
Esempio n. 13
0
 static void ReadDeliveryAnnotationsSection(AmqpMessageReader reader, AmqpMessage message)
 {
     message.DeliveryAnnotations = ReadMapSection <DeliveryAnnotations>(reader);
 }
Esempio n. 14
0
 public void ReleaseMessage(AmqpMessage message)
 {
     this.DisposeMessage(message, AmqpConstants.ReleasedOutcome, true, false);
 }
Esempio n. 15
0
        public static void UpdateEventDataHeaderAndProperties(AmqpMessage amqpMessage, EventData data)
        {
            string              str;
            string              str1;
            DateTime            dateTime;
            long                num;
            string              str2;
            ArraySegment <byte> deliveryTag = amqpMessage.DeliveryTag;

            Fx.AssertAndThrow(true, "AmqpMessage should always contain delivery tag.");
            data.DeliveryTag = amqpMessage.DeliveryTag;
            SectionFlag sections = amqpMessage.Sections;

            if ((int)(sections & SectionFlag.MessageAnnotations) != 0)
            {
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <string>("x-opt-publisher", out str))
                {
                    data.Publisher = str;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <string>("x-opt-partition-key", out str1))
                {
                    data.PartitionKey = str1;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <DateTime>("x-opt-enqueued-time", out dateTime))
                {
                    data.EnqueuedTimeUtc = dateTime;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <long>("x-opt-sequence-number", out num))
                {
                    data.SequenceNumber = num;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <string>("x-opt-offset", out str2))
                {
                    data.Offset = str2;
                }
            }
            if ((int)(sections & SectionFlag.ApplicationProperties) != 0)
            {
                foreach (KeyValuePair <MapKey, object> map in (IEnumerable <KeyValuePair <MapKey, object> >)amqpMessage.ApplicationProperties.Map)
                {
                    object obj = null;
                    if (!MessageConverter.TryGetNetObjectFromAmqpObject(map.Value, MappingType.ApplicationProperty, out obj))
                    {
                        continue;
                    }
                    data.Properties[map.Key.ToString()] = obj;
                }
            }
            if ((int)(sections & SectionFlag.Properties) != 0)
            {
                foreach (KeyValuePair <string, object> dictionary in amqpMessage.Properties.ToDictionary())
                {
                    if (dictionary.Value is MessageId || dictionary.Value is Address || dictionary.Value is AmqpSymbol)
                    {
                        data.SystemProperties.Add(dictionary.Key, dictionary.Value.ToString());
                    }
                    else
                    {
                        data.SystemProperties.Add(dictionary);
                    }
                }
            }
        }
Esempio n. 16
0
 public void DisposeMessage(AmqpMessage message, DeliveryState state, bool settled, bool batchable)
 {
     message.Batchable = batchable;
     this.DisposeDelivery(message, settled, state);
 }
Esempio n. 17
0
        public static BrokeredMessage ClientGetMessage(AmqpMessage amqpMessage)
        {
            BrokeredMessage brokeredMessage;

            if ((int)(amqpMessage.BodyType & SectionFlag.Data) != 0 || (int)(amqpMessage.BodyType & SectionFlag.AmqpSequence) != 0)
            {
                brokeredMessage = new BrokeredMessage(MessageConverter.GetMessageBodyStream(amqpMessage), true);
            }
            else if ((int)(amqpMessage.BodyType & SectionFlag.AmqpValue) == 0)
            {
                brokeredMessage = new BrokeredMessage();
            }
            else
            {
                object value = null;
                if (!MessageConverter.TryGetNetObjectFromAmqpObject(amqpMessage.ValueBody.Value, MappingType.MessageBody, out value))
                {
                    value = amqpMessage.ValueBody.Value;
                }
                brokeredMessage = new BrokeredMessage(value, amqpMessage.BodyStream);
            }
            SectionFlag sections = amqpMessage.Sections;

            if ((int)(sections & SectionFlag.Header) != 0)
            {
                if (amqpMessage.Header.Ttl.HasValue)
                {
                    uint?ttl = amqpMessage.Header.Ttl;
                    brokeredMessage.TimeToLive = TimeSpan.FromMilliseconds((double)((float)ttl.Value));
                }
                if (amqpMessage.Header.DeliveryCount.HasValue)
                {
                    brokeredMessage.DeliveryCount = (int)(amqpMessage.Header.DeliveryCount.Value + 1);
                }
            }
            if ((int)(sections & SectionFlag.Properties) != 0)
            {
                if (amqpMessage.Properties.MessageId != null)
                {
                    brokeredMessage.MessageId = amqpMessage.Properties.MessageId.ToString();
                }
                if (amqpMessage.Properties.CorrelationId != null)
                {
                    brokeredMessage.CorrelationId = amqpMessage.Properties.CorrelationId.ToString();
                }
                if (amqpMessage.Properties.ContentType.Value != null)
                {
                    brokeredMessage.ContentType = amqpMessage.Properties.ContentType.Value;
                }
                if (amqpMessage.Properties.Subject != null)
                {
                    brokeredMessage.Label = amqpMessage.Properties.Subject;
                }
                if (amqpMessage.Properties.To != null)
                {
                    brokeredMessage.To = amqpMessage.Properties.To.ToString();
                }
                if (amqpMessage.Properties.ReplyTo != null)
                {
                    brokeredMessage.ReplyTo = amqpMessage.Properties.ReplyTo.ToString();
                }
                if (amqpMessage.Properties.GroupId != null)
                {
                    brokeredMessage.SessionId = amqpMessage.Properties.GroupId;
                }
                if (amqpMessage.Properties.ReplyToGroupId != null)
                {
                    brokeredMessage.ReplyToSessionId = amqpMessage.Properties.ReplyToGroupId;
                }
            }
            if ((int)(sections & SectionFlag.ApplicationProperties) != 0)
            {
                foreach (KeyValuePair <MapKey, object> map in (IEnumerable <KeyValuePair <MapKey, object> >)amqpMessage.ApplicationProperties.Map)
                {
                    object obj = null;
                    if (!MessageConverter.TryGetNetObjectFromAmqpObject(map.Value, MappingType.ApplicationProperty, out obj))
                    {
                        continue;
                    }
                    brokeredMessage.Properties[map.Key.ToString()] = obj;
                }
            }
            if ((int)(sections & SectionFlag.MessageAnnotations) != 0)
            {
                foreach (KeyValuePair <MapKey, object> keyValuePair in (IEnumerable <KeyValuePair <MapKey, object> >)amqpMessage.MessageAnnotations.Map)
                {
                    string str  = keyValuePair.Key.ToString();
                    string str1 = str;
                    string str2 = str1;
                    if (str1 != null)
                    {
                        switch (str2)
                        {
                        case "x-opt-enqueued-time":
                        {
                            brokeredMessage.EnqueuedTimeUtc = (DateTime)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-scheduled-enqueue-time":
                        {
                            brokeredMessage.ScheduledEnqueueTimeUtc = (DateTime)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-sequence-number":
                        {
                            brokeredMessage.SequenceNumber = (long)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-offset":
                        {
                            brokeredMessage.EnqueuedSequenceNumber = (long)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-locked-until":
                        {
                            brokeredMessage.LockedUntilUtc = (DateTime)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-publisher":
                        {
                            brokeredMessage.Publisher = (string)keyValuePair.Value;
                            continue;
                        }

                        case "x-opt-partition-key":
                        {
                            brokeredMessage.PartitionKey = (string)keyValuePair.Value;
                            continue;
                        }
                        }
                    }
                    object obj1 = null;
                    if (!MessageConverter.TryGetNetObjectFromAmqpObject(keyValuePair.Value, MappingType.ApplicationProperty, out obj1))
                    {
                        continue;
                    }
                    brokeredMessage.Properties[str] = obj1;
                }
            }
            if (amqpMessage.DeliveryTag.Count == 16)
            {
                byte[] numArray = new byte[16];
                byte[] array    = amqpMessage.DeliveryTag.Array;
                ArraySegment <byte> deliveryTag = amqpMessage.DeliveryTag;
                Buffer.BlockCopy((Array)array, deliveryTag.Offset, numArray, 0, 16);
                brokeredMessage.LockToken = new Guid(numArray);
            }
            brokeredMessage.AttachDisposables(new AmqpMessage[] { amqpMessage });
            return(brokeredMessage);
        }
Esempio n. 18
0
 public void Done(bool completedSynchronously, AmqpMessage response)
 {
     this.response = response;
     base.CompleteSelf(completedSynchronously);
 }
Esempio n. 19
0
        public static void UpdateBrokeredMessageHeaderAndProperties(AmqpMessage amqpMessage, BrokeredMessage message)
        {
            DateTime    dateTime;
            string      str;
            string      str1;
            SectionFlag sections = amqpMessage.Sections;

            if ((int)(sections & SectionFlag.Header) != 0 && amqpMessage.Header.Ttl.HasValue)
            {
                uint?ttl = amqpMessage.Header.Ttl;
                message.TimeToLive = TimeSpan.FromMilliseconds((double)((float)ttl.Value));
            }
            if ((int)(sections & SectionFlag.Properties) != 0)
            {
                if (amqpMessage.Properties.MessageId != null)
                {
                    message.MessageId = amqpMessage.Properties.MessageId.ToString();
                }
                if (amqpMessage.Properties.CorrelationId != null)
                {
                    message.CorrelationId = amqpMessage.Properties.CorrelationId.ToString();
                }
                if (amqpMessage.Properties.ContentType.Value != null)
                {
                    message.ContentType = amqpMessage.Properties.ContentType.Value;
                }
                if (amqpMessage.Properties.Subject != null)
                {
                    message.Label = amqpMessage.Properties.Subject;
                }
                if (amqpMessage.Properties.To != null)
                {
                    message.To = amqpMessage.Properties.To.ToString();
                }
                if (amqpMessage.Properties.ReplyTo != null)
                {
                    message.ReplyTo = amqpMessage.Properties.ReplyTo.ToString();
                }
                if (amqpMessage.Properties.GroupId != null)
                {
                    message.SessionId = amqpMessage.Properties.GroupId;
                }
                if (amqpMessage.Properties.ReplyToGroupId != null)
                {
                    message.ReplyToSessionId = amqpMessage.Properties.ReplyToGroupId;
                }
            }
            if ((int)(sections & SectionFlag.MessageAnnotations) != 0)
            {
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <DateTime>("x-opt-scheduled-enqueue-time", out dateTime))
                {
                    message.ScheduledEnqueueTimeUtc = dateTime;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <string>("x-opt-publisher", out str))
                {
                    message.Publisher = str;
                }
                if (amqpMessage.MessageAnnotations.Map.TryGetValue <string>("x-opt-partition-key", out str1))
                {
                    message.PartitionKey = str1;
                }
            }
            if ((int)(sections & SectionFlag.ApplicationProperties) != 0)
            {
                foreach (KeyValuePair <MapKey, object> map in (IEnumerable <KeyValuePair <MapKey, object> >)amqpMessage.ApplicationProperties.Map)
                {
                    object obj = null;
                    if (!MessageConverter.TryGetNetObjectFromAmqpObject(map.Value, MappingType.ApplicationProperty, out obj))
                    {
                        continue;
                    }
                    message.InternalProperties[map.Key.ToString()] = obj;
                }
            }
        }
Esempio n. 20
0
 void OnMessage(AmqpMessage message)
 {
     this.messages.EnqueueAndDispatch(message, null, false);
     this.Link.DisposeDelivery(message, true, message.State);
 }
Esempio n. 21
0
 void AddBodyBuffer(ArraySegment <byte> buffer)
 {
     AmqpMessage.EnsureInitialized <List <ArraySegment <byte> > >(ref this.bodyBuffers);
     this.bodyBuffers.Add(buffer);
 }