コード例 #1
0
 public LinkDeserializationException(byte[] body, LinkMessageProperties properties, LinkRecieveMessageProperties recieveProperties, Exception innerException)
     : base("Cannot deserialize message, see InnerException for details", innerException)
 {
     Body = body;
     Properties = properties;
     RecieveProperties = recieveProperties;
 }
コード例 #2
0
 public LinkProducerQueueMessage(byte[] body, LinkMessageProperties properties,
     LinkPublishProperties publishProperties, CancellationToken cancellation)
     : base(cancellation)
 {
     Body = body;
     Properties = properties;
     PublishProperties = publishProperties;
 }
コード例 #3
0
        public void CorrelationIdProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.CorrelationIdPresent);
            Assert.Null(props.CorrelationId);

            props.CorrelationId = "test";

            Assert.Equal(props.CorrelationId, "test");
            Assert.True(props.CorrelationIdPresent);
        }
コード例 #4
0
        public void ContentTypeProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.ContentTypePresent);
            Assert.Null(props.ContentType);

            props.ContentType = "test";

            Assert.Equal(props.ContentType, "test");
            Assert.True(props.ContentTypePresent);
        }
コード例 #5
0
        public void ContentEncodingProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.ContentEncodingPresent);
            Assert.Null(props.ContentEncoding);

            props.ContentEncoding = "test";

            Assert.Equal(props.ContentEncoding, "test");
            Assert.True(props.ContentEncodingPresent);
        }
コード例 #6
0
        public void ExpirationProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.ExpirationPresent);
            Assert.Null(props.Expiration);

            props.Expiration = TimeSpan.FromSeconds(1);

            Assert.Equal(TimeSpan.FromSeconds(1), props.Expiration);
            Assert.True(props.ExpirationPresent);
        }
コード例 #7
0
 public void CopyTo()
 {
     var props = new LinkMessageProperties();
 }
コード例 #8
0
        public void TimeStampProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.TimeStampPresent);
            Assert.Null(props.TimeStamp);

            props.TimeStamp = new DateTime(2015, 01, 01).ToUnixTime();

            Assert.Equal(new DateTime(2015, 01, 01), props.TimeStamp.Value.FromUnixTime());
            Assert.True(props.TimeStampPresent);
        }
コード例 #9
0
 public LinkMessageProperties Clone()
 {
     var ret = new LinkMessageProperties();
     CopyTo(ret);
     return ret;
 }
コード例 #10
0
        public void ReplyToProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.ReplyToPresent);
            Assert.Null(props.ReplyTo);

            props.ReplyTo = "test";

            Assert.Equal("test", props.ReplyTo);
            Assert.True(props.ReplyToPresent);
        }
コード例 #11
0
        public void Enqueue(byte[] body, LinkMessageProperties properties, LinkRecieveMessageProperties recieveProperties, LinkMessageOnAckAsyncDelegate onAck,
            LinkMessageOnNackAsyncDelegate onNack)
        {
            if (_disposedCancellation.IsCancellationRequested)
                throw new ObjectDisposedException(GetType().Name);

            var cancellation = _messageCancellation;

            try
            {
                var message = new LinkMessage<byte[]>(body, properties, recieveProperties, onAck, onNack, cancellation);
                var holder = new MessageHolder(message, cancellation);
                _messageQueue.Enqueue(holder, cancellation);
            }
            catch (InvalidOperationException)
            {
                throw new ObjectDisposedException(GetType().Name);
            }
        }
コード例 #12
0
 public ILinkProducerConfigurationBuilder MessageProperties(LinkMessageProperties value)
 {
     Configuration.MessageProperties = value;
     return this;
 }
コード例 #13
0
 /// <summary>
 /// Makes clone of instance
 /// </summary>
 public static LinkMessageProperties Clone(this LinkMessageProperties @this)
 => new LinkMessageProperties().Extend(@this);
コード例 #14
0
 public void Ctor()
 {
     var props = new LinkMessageProperties();
 }
コード例 #15
0
        /// <summary>
        /// Extend instance with other instances, returns instance.
        /// </summary>
        public static LinkMessageProperties Extend(this LinkMessageProperties @this,
                                                   params LinkMessageProperties[] others)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            if (others?.Any() == true)
            {
                foreach (var other in others)
                {
                    if (other.AppId != null)
                    {
                        @this.AppId = other.AppId;
                    }
                    if (other.ClusterId != null)
                    {
                        @this.ClusterId = other.ClusterId;
                    }
                    if (other.ContentEncoding != null)
                    {
                        @this.ContentEncoding = other.ContentEncoding;
                    }
                    if (other.ContentType != null)
                    {
                        @this.ContentType = other.ContentType;
                    }
                    if (other.CorrelationId != null)
                    {
                        @this.CorrelationId = other.CorrelationId;
                    }
                    if (other.DeliveryMode != LinkDeliveryMode.Default)
                    {
                        @this.DeliveryMode = other.DeliveryMode;
                    }
                    if (other.ReplyTo != null)
                    {
                        @this.ReplyTo = other.ReplyTo;
                    }
                    if (other.Expiration != null)
                    {
                        @this.Expiration = other.Expiration;
                    }
                    if (other.MessageId != null)
                    {
                        @this.MessageId = other.MessageId;
                    }
                    if (other.TimeStamp != null)
                    {
                        @this.TimeStamp = other.TimeStamp;
                    }
                    if (other.Type != null)
                    {
                        @this.Type = other.Type;
                    }
                    if (other.UserId != null)
                    {
                        @this.UserId = other.UserId;
                    }
                    if (other.Priority != null)
                    {
                        @this.Priority = other.Priority;
                    }

                    if (other.Headers.Any())
                    {
                        foreach (var header in other.Headers)
                        {
                            if (header.Value != null)
                            {
                                @this.Headers[header.Key] = header.Value;
                            }
                        }
                    }
                }
            }

            return(@this);
        }
コード例 #16
0
        /// <summary>
        /// Extends instance with <see cref="IBasicProperties"/> instances, return instance
        /// </summary>
        internal static LinkMessageProperties Extend(this LinkMessageProperties @this, params IBasicProperties[] others)
        {
            if (@this == null)
            {
                throw new ArgumentNullException(nameof(@this));
            }

            if (others?.Any() == true)
            {
                foreach (var other in others)
                {
                    if (other.IsAppIdPresent())
                    {
                        @this.AppId = other.AppId;
                    }
                    if (other.IsClusterIdPresent())
                    {
                        @this.ClusterId = other.ClusterId;
                    }
                    if (other.IsContentEncodingPresent())
                    {
                        @this.ContentEncoding = other.ContentEncoding;
                    }
                    if (other.IsContentTypePresent())
                    {
                        @this.ContentType = other.ContentType;
                    }
                    if (other.IsCorrelationIdPresent())
                    {
                        @this.CorrelationId = other.CorrelationId;
                    }
                    if (other.IsDeliveryModePresent())
                    {
                        @this.DeliveryMode = (LinkDeliveryMode)other.DeliveryMode;
                    }
                    if (other.IsReplyToPresent())
                    {
                        @this.ReplyTo = other.ReplyTo;
                    }
                    if (other.IsExpirationPresent())
                    {
                        @this.Expiration = TimeSpan.FromMilliseconds(int.Parse(other.Expiration));
                    }
                    if (other.IsMessageIdPresent())
                    {
                        @this.MessageId = other.MessageId;
                    }
                    if (other.IsTimestampPresent())
                    {
                        @this.TimeStamp = other.Timestamp.UnixTime;
                    }
                    if (other.IsTypePresent())
                    {
                        @this.Type = other.Type;
                    }
                    if (other.IsUserIdPresent())
                    {
                        @this.UserId = other.UserId;
                    }
                    if (other.IsPriorityPresent())
                    {
                        @this.Priority = other.Priority;
                    }

                    if (other.IsHeadersPresent() && other.Headers?.Any() == true)
                    {
                        foreach (var header in other.Headers)
                        {
                            if (header.Value != null)
                            {
                                @this.Headers[header.Key] = header.Value;
                            }
                        }
                    }
                }
            }

            return(@this);
        }
コード例 #17
0
 public void SetMessageId(byte[] body, LinkMessageProperties properties, LinkPublishProperties publishProperties)
 {
     properties.MessageId = Guid.NewGuid().ToString("D");
 }
コード例 #18
0
        public void CopyFrom(LinkMessageProperties from)
        {
            if (from == null)
                throw new ArgumentNullException(nameof(from));

            if (from.AppIdPresent) AppId = from.AppId;
            if (from.ClusterIdPresent) ClusterId = from.ClusterId;
            if (from.ContentEncodingPresent) ContentEncoding = from.ContentEncoding;
            if (from.ContentTypePresent) ContentType = from.ContentType;
            if (from.CorrelationIdPresent) CorrelationId = from.CorrelationId;
            if (from.DeliveryModePresent) DeliveryMode = @from.DeliveryMode;
            if (from.ReplyToPresent) ReplyTo = from.ReplyTo;
            if (from.ExpirationPresent) Expiration = from.Expiration;
            if (from.MessageIdPresent) MessageId = from.MessageId;
            if (from.TimeStampPresent) TimeStamp = from.TimeStamp;
            if (from.TypePresent) Type = from.Type;
            if (from.UserIdPresent) UserId = from.UserId;
            if (from.PriorityPresent) Priority = from.Priority;

            if (from.HeadersPresent)
            {
                foreach (var header in from.Headers)
                {
                    Headers[header.Key] = header.Value;
                }
            }
        }
コード例 #19
0
        internal void CopyTo(LinkMessageProperties to)
        {
            if (to == null)
                throw new ArgumentNullException(nameof(to));

            if (AppIdPresent) to.AppId = AppId;
            if (ClusterIdPresent) to.ClusterId = ClusterId;
            if (ContentEncodingPresent) to.ContentEncoding = ContentEncoding;
            if (ContentTypePresent) to.ContentType = ContentType;
            if (CorrelationIdPresent) to.CorrelationId = CorrelationId;
            if (DeliveryModePresent) to.DeliveryMode = DeliveryMode;
            if (ReplyToPresent) to.ReplyTo = ReplyTo;
            if (ExpirationPresent) to.Expiration = Expiration;
            if (MessageIdPresent) to.MessageId = MessageId;
            if (TimeStampPresent) to.TimeStamp = TimeStamp;
            if (TypePresent) to.Type = Type;
            if (UserIdPresent) to.UserId = UserId;
            if (PriorityPresent) to.Priority = Priority;

            if (HeadersPresent)
            {
                foreach (var header in Headers)
                {
                    to.Headers[header.Key] = header.Value;
                }
            }
        }
コード例 #20
0
        public void DeliveryModeProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.DeliveryModePresent);
            Assert.Equal(props.DeliveryMode, LinkMessageDeliveryMode.Transient);

            props.DeliveryMode = LinkMessageDeliveryMode.Persistent;

            Assert.Equal(LinkMessageDeliveryMode.Persistent, props.DeliveryMode);
            Assert.True(props.DeliveryModePresent);

            props = new LinkMessageProperties();

            Assert.False(props.DeliveryModePresent);
            Assert.Equal(LinkMessageDeliveryMode.Transient, props.DeliveryMode);

            props.DeliveryMode = LinkMessageDeliveryMode.Transient;

            Assert.Equal(LinkMessageDeliveryMode.Transient, props.DeliveryMode);
            Assert.True(props.DeliveryModePresent);
        }
コード例 #21
0
        public void HeadersProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.HeadersPresent);
            Assert.Empty(props.Headers);

            props.Headers.Add("test", 1);

            Assert.Equal(props.Headers["test"], 1);
            Assert.True(props.HeadersPresent);
            Assert.NotEmpty(props.Headers);
        }
コード例 #22
0
 /// <inheritdoc />
 public void SetMessageId(byte[] body, LinkMessageProperties properties, LinkPublishProperties publishProperties)
 {
     properties.MessageId = Guid.NewGuid().ToString("D");
 }
コード例 #23
0
        public void MessageIdProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.MessageIdPresent);
            Assert.Null(props.MessageId);

            props.MessageId = "test";

            Assert.Equal("test", props.MessageId);
            Assert.True(props.MessageIdPresent);
        }
コード例 #24
0
 public static object Deserialize(this ILinkMessageSerializer @this, Type bodyType,
     byte[] body, LinkMessageProperties properties)
 {
     var genericMethod = DeserializeMethod.MakeGenericMethod(bodyType);
     return genericMethod.Invoke(@this, new object[] { body, properties });
 }
コード例 #25
0
        public void PriorityProperty()
        {
            var props = new LinkMessageProperties();

            Assert.False(props.PriorityPresent);
            Assert.Null(props.Priority);

            props.Priority = 5;

            Assert.Equal((byte) 5, props.Priority);
            Assert.True(props.PriorityPresent);
        }