コード例 #1
0
        public void GeneratesMessageIdBy(INewId instance)
        {
            if (instance == null)
                throw new ArgumentNullException(nameof(instance));

            IdGenerator = instance;
        }
コード例 #2
0
        internal virtual IBasicProperties BuildBasicProperties(IMessageTypeResolver resolver,
                                                               IDateTimeProvider dateTimeProvider,
                                                               INewId idGenerator)
        {
            var properties = new BasicProperties
            {
                Headers         = new Dictionary <String, Object>(),
                Persistent      = false,
                ContentType     = Headers.ContentType ?? SerializationConfiguration.DefaultContentType,
                ContentEncoding = Headers.ContentEncoding ?? SerializationConfiguration.DefaultContentEncoding,
                MessageId       = Headers.MessageId ?? idGenerator.Next(),
                Timestamp       = new AmqpTimestamp(Headers.Timestamp <= 0L
                                             ? dateTimeProvider.UtcNow().ToUnixTimestamp()
                                             : Headers.Timestamp)
            };

            var binding = resolver.Resolve <TMessage>();

            properties.Type = binding.RawName;

            if (binding.ExpiresAfter.HasValue)
            {
                properties.Expiration = binding.ExpiresAfter
                                        .GetValueOrDefault()
                                        .TotalMilliseconds
                                        .ToString(CultureInfo.InvariantCulture);
            }

            Headers.NonReservedHeaders().ToList().ForEach(_ => properties.Headers.Add(_.Key, _.Value));

            return(properties);
        }
コード例 #3
0
        internal override IBasicProperties BuildBasicProperties(IMessageTypeResolver resolver,
                                                                IDateTimeProvider dateTimeProvider,
                                                                INewId idGenerator)
        {
            var properties = base.BuildBasicProperties(resolver, dateTimeProvider, idGenerator);

            properties.Persistent = true;
            return(properties);
        }
コード例 #4
0
        public void GeneratesMessageIdBy(INewId instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }

            IdGenerator = instance;
        }