当前位置: 首页>>代码示例>>C#>>正文


C# IBasicProperties类代码示例

本文整理汇总了C#中IBasicProperties的典型用法代码示例。如果您正苦于以下问题:C# IBasicProperties类的具体用法?C# IBasicProperties怎么用?C# IBasicProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IBasicProperties类属于命名空间,在下文中一共展示了IBasicProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToMessageProperties

        /// <summary>Converts from BasicProperties to MessageProperties.</summary>
        /// <param name="source">The source.</param>
        /// <param name="envelope">The envelope.</param>
        /// <param name="charset">The charset.</param>
        /// <returns>The message properties.</returns>
        public MessageProperties ToMessageProperties(IBasicProperties source, BasicGetResult envelope, string charset)
        {
            var target = new MessageProperties();
            var headers = source.Headers;
            if (headers != null && headers.Count > 0)
            {
                foreach (DictionaryEntry entry in headers)
                {
                    var value = entry.Value;

                    /*
                    if (value is LongString) 
                    {
                        value = this.convertLongString((LongString) value, charset);
                    }
                    */
                    target.Headers[(string)entry.Key] = value;
                }
            }

            target.Timestamp = source.Timestamp.ToDateTime();
            target.MessageId = source.MessageId;
            target.UserId = source.UserId;
            target.AppId = source.AppId;
            target.ClusterId = source.ClusterId;
            target.Type = source.Type;
            target.DeliveryMode = (MessageDeliveryMode)source.DeliveryMode;
            target.Expiration = source.Expiration;
            target.Priority = source.Priority;
            target.ContentType = source.ContentType;
            target.ContentEncoding = source.ContentEncoding;
            var correlationId = source.CorrelationId;
            if (correlationId != null)
            {
                try
                {
                    target.CorrelationId = source.CorrelationId.ToByteArrayWithEncoding(charset);
                }
                catch (Exception ex)
                {
                    throw new AmqpUnsupportedEncodingException(ex);
                }
            }

            var replyTo = source.ReplyTo;
            if (replyTo != null)
            {
                target.ReplyTo = replyTo;
            }

            if (envelope != null)
            {
                target.ReceivedExchange = envelope.Exchange;
                target.ReceivedRoutingKey = envelope.RoutingKey;
                target.Redelivered = envelope.Redelivered;
                target.DeliveryTag = (long)envelope.DeliveryTag;
            }

            return target;
        }
开发者ID:yonglehou,项目名称:spring-net-amqp,代码行数:65,代码来源:DefaultMessagePropertiesConverter.cs

示例2: HandleBasicDeliver

 public void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)
 {
     if (Deliver != null)
     {
         Deliver(this, new DeliverEventArgs(consumerTag, deliveryTag, redelivered, exchange, this.Queue, routingKey, properties, body));
     }
 }
开发者ID:nordbergm,项目名称:NSimpleBus,代码行数:7,代码来源:QueueActivityConsumer.cs

示例3: HandleBasicDeliver

        public override void HandleBasicDeliver(
            string consumerTag,
            ulong deliveryTag,
            bool redelivered,
            string exchange,
            string routingKey,
            IBasicProperties properties,
            byte[] body )
        {
            Loop.Enqueue( () =>
                {
                    var envelope = GetEnvelope( properties );
                    envelope.ByteStream = body;
                    envelope.Initialize(
                        consumerTag,
                        properties,
                        deliveryTag,
                        exchange,
                        Proxy,
                        redelivered,
                        routingKey
                        );

                    var translatedEnvelope = DeserializeMessage( envelope );
                    DispatchResult( translatedEnvelope );
                } );
        }
开发者ID:cmgator,项目名称:Symbiote,代码行数:27,代码来源:RabbitQueueListener.cs

示例4: Enqueue

 /// <summary>
 /// 入队操作
 /// </summary>
 /// <param name="bytes"></param>
 /// <param name="property"></param>
 /// <param name="persistent"></param>
 public static void Enqueue(byte[] bytes, IBasicProperties property, bool persistent = false)
 {
     IModel channel = channels[new Random().Next(0, channels_num)];  //随机选取channel发送数据
     if (property == null) property = channel.CreateBasicProperties();  //额外的属性,添加消息头的
     property.SetPersistent(persistent);  //消息持久化
     channel.BasicPublish(exchange_name, route_key, property, bytes);
 }
开发者ID:wangyang602117818,项目名称:EasyOa.Common,代码行数:13,代码来源:LogEnqueue.cs

示例5: HandleBasicDeliver

        public override void HandleBasicDeliver(String consumerTag,
                                                UInt64 deliveryTag,
                                                Boolean redelivered,
                                                String exchange,
                                                String routingKey,
                                                IBasicProperties properties,
                                                Byte[] body)
        {
            base.HandleBasicDeliver(consumerTag,
                                    deliveryTag,
                                    redelivered,
                                    exchange,
                                    routingKey,
                                    properties,
                                    body);

            var args = new BasicDeliverEventArgs
                           {
                               ConsumerTag = consumerTag,
                               DeliveryTag = deliveryTag,
                               Redelivered = redelivered,
                               Exchange = exchange,
                               RoutingKey = routingKey,
                               BasicProperties = properties,
                               Body = body
                           };

            ConsumeInternalAsync(args);
        }
开发者ID:emadb,项目名称:Carrot,代码行数:29,代码来源:ConsumerBase.cs

示例6: BasicPropertiesWrapper

        public BasicPropertiesWrapper(IBasicProperties basicProperties)
        {
            ContentType = basicProperties.ContentType;
            ContentEncoding = basicProperties.ContentEncoding;
            DeliveryMode = basicProperties.DeliveryMode;
            Priority = basicProperties.Priority;
            CorrelationId = basicProperties.CorrelationId;
            ReplyTo = basicProperties.ReplyTo;
            Expiration = basicProperties.Expiration;
            MessageId = basicProperties.MessageId;
            Timestamp = basicProperties.Timestamp.UnixTime;
            Type = basicProperties.Type;
            UserId = basicProperties.UserId;
            AppId = basicProperties.AppId;
            ClusterId = basicProperties.ClusterId;

            if (basicProperties.IsHeadersPresent())
            {
                Headers = new HybridDictionary();
                foreach (DictionaryEntry header in basicProperties.Headers)
                {
                    Headers.Add(header.Key, header.Value);
                }
            }
        }
开发者ID:sovanesyan,项目名称:Burrow.NET,代码行数:25,代码来源:BurrowError.cs

示例7: HandleBasicDeliver

 public void HandleBasicDeliver(IBasicConsumer consumer,
                                string consumerTag,
                                ulong deliveryTag,
                                bool redelivered,
                                string exchange,
                                string routingKey,
                                IBasicProperties basicProperties,
                                byte[] body)
 {
     UnlessShuttingDown(() =>
     {
         try
         {
             consumer.HandleBasicDeliver(consumerTag,
                                         deliveryTag,
                                         redelivered,
                                         exchange,
                                         routingKey,
                                         basicProperties,
                                         body);
         }
         catch (Exception e)
         {
             var details = new Dictionary<string, object>()
             {
                 {"consumer", consumer},
                 {"context",  "HandleBasicDeliver"}
             };
             model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
         }
     });
 }
开发者ID:hanxinimm,项目名称:rabbitmq-dotnet-client,代码行数:32,代码来源:ConcurrentConsumerDispatcher.cs

示例8: FillRabbitMqProperties

        public static IBasicProperties FillRabbitMqProperties(TransportMessage message, IBasicProperties properties)
        {
            properties.MessageId = message.Id;

            properties.CorrelationId = message.CorrelationId;

            if (message.TimeToBeReceived < TimeSpan.MaxValue)
                properties.Expiration = message.TimeToBeReceived.TotalMilliseconds.ToString();

            properties.SetPersistent(message.Recoverable);

            properties.Headers = message.Headers;

            if (message.Headers.ContainsKey(Headers.EnclosedMessageTypes))
            {
                properties.Type = message.Headers[Headers.EnclosedMessageTypes].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
            }

            if (message.Headers.ContainsKey(Headers.ContentType))
                properties.ContentType = message.Headers[Headers.ContentType];
            else
            {
                properties.ContentType = "application/octet-stream";
            }

            if (message.ReplyToAddress != null && message.ReplyToAddress != Address.Undefined)
                properties.ReplyTo = message.ReplyToAddress.Queue;

            return properties;
        }
开发者ID:afyles,项目名称:NServiceBus,代码行数:30,代码来源:RabbitMqTransportMessageExtensions.cs

示例9: CopyFrom

        public void CopyFrom(IBasicProperties basicProperties)
        {
            Preconditions.CheckNotNull(basicProperties, "basicProperties");

            if (basicProperties.IsContentTypePresent())         ContentType         = basicProperties.ContentType;
            if (basicProperties.IsContentEncodingPresent())     ContentEncoding     = basicProperties.ContentEncoding;
            if (basicProperties.IsDeliveryModePresent())        DeliveryMode        = basicProperties.DeliveryMode;
            if (basicProperties.IsPriorityPresent())            Priority            = basicProperties.Priority;
            if (basicProperties.IsCorrelationIdPresent())       CorrelationId       = basicProperties.CorrelationId;
            if (basicProperties.IsReplyToPresent())             ReplyTo             = basicProperties.ReplyTo;
            if (basicProperties.IsExpirationPresent())          Expiration          = basicProperties.Expiration;
            if (basicProperties.IsMessageIdPresent())           MessageId           = basicProperties.MessageId;
            if (basicProperties.IsTimestampPresent())           Timestamp           = basicProperties.Timestamp.UnixTime;
            if (basicProperties.IsTypePresent())                Type                = basicProperties.Type;
            if (basicProperties.IsUserIdPresent())              UserId              = basicProperties.UserId;
            if (basicProperties.IsAppIdPresent())               AppId               = basicProperties.AppId;
            if (basicProperties.IsClusterIdPresent())           ClusterId           = basicProperties.ClusterId;

            if (basicProperties.IsHeadersPresent())
            {
                foreach (var header in basicProperties.Headers)
                {
                    Headers.Add(header.Key, header.Value);
                }
            }
        }
开发者ID:fryderykhuang,项目名称:EasyNetQ,代码行数:26,代码来源:MessageProperties.cs

示例10: HandleBasicDeliver

        public override void HandleBasicDeliver(string consumerTag, ulong deliveryTag, bool redelivered, string exchange, string routingKey, IBasicProperties properties, byte[] body)
        {
            if (!Model.IsOpen) return;

            var messageObject = Serializer.Deserialize(body, Subscription.MessageType);
            var propertyHeaders = properties.Headers;
            var headers = new Dictionary<string, string>();
            if (propertyHeaders != null)
            {
                foreach (var propertyHeader in propertyHeaders)
                {
                    headers.Add(propertyHeader.Key, Encoding.UTF8.GetString((byte[])propertyHeader.Value));
                }
            }

            Log.Info("Executing handler for delivery tag '{0}' from queue '{1}'", deliveryTag, Subscription.QueueName);
            Log.Debug("Message with delivery tag '{0}': '{1}'", deliveryTag, Encoding.UTF8.GetString(body));

            try
            {
                ExecuteSubscriptionMessageHandler(properties, messageObject, headers);

                Model.BasicAck(deliveryTag, false);
            }
            catch (Exception e)
            {
                Model.BasicNack(deliveryTag, false, true);

                Log.Error(e, "Exception executing message handler for subscription '{0}'!", Subscription.SubscriptionId);

                throw;
            }
        }
开发者ID:ReactiveServices,项目名称:ReactiveServices.MessageBus.RabbitMQ,代码行数:33,代码来源:RabbitMQConsumer.cs

示例11: HandleBasicDeliver

        public void HandleBasicDeliver(ulong deliveryTag, IBasicProperties properties, object body)
        {
            if (!Model.IsOpen) return;

            Model.BasicAck(deliveryTag, false); // TODO: Review - Check case of failure on Message Handler

            Task.Run(() =>
            {
                var messageObject = body;

                var propertyHeaders = properties.Headers;
                var headers = new Dictionary<string, string>();
                if (propertyHeaders != null)
                {
                    foreach (var propertyHeader in propertyHeaders)
                    {
                        headers.Add(propertyHeader.Key, (string)propertyHeader.Value);
                    }
                }

                Log.Info("Executing handler for delivery tag '{0}' from queue '{1}'", deliveryTag, Subscription.QueueName);

                try
                {
                    ExecuteSubscriptionMessageHandler(properties, messageObject, headers);
                }
                catch (Exception e)
                {
                    Log.Error(e, "Exception executing message handler for subscription '{0}'!", Subscription.SubscriptionId);
                    throw;
                }
            });
        }
开发者ID:ReactiveServices,项目名称:ReactiveServices.MessageBus.InSingleProcessMemory,代码行数:33,代码来源:InSingleProcessMemoryConsumer.cs

示例12: HandleBasicDeliver

 ///<summary>Fires the Received event.</summary>
 public override void HandleBasicDeliver(string consumerTag,
                                         ulong deliveryTag,
                                         bool redelivered,
                                         string exchange,
                                         string routingKey,
                                         IBasicProperties properties,
                                         byte[] body)
 {
     base.HandleBasicDeliver(consumerTag,
                             deliveryTag,
                             redelivered,
                             exchange,
                             routingKey,
                             properties,
                             body);
     if (Received != null) {
         Received(this, new BasicDeliverEventArgs(consumerTag,
                                                  deliveryTag,
                                                  redelivered,
                                                  exchange,
                                                  routingKey,
                                                  properties,
                                                  body));
     }
 }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:26,代码来源:EventingBasicConsumer.cs

示例13: InSingleProcessMemoryMessage

 public InSingleProcessMemoryMessage(ulong deliveryTag, string routingKey, IBasicProperties properties,
     object body)
 {
     DeliveryTag = deliveryTag;
     RoutingKey = routingKey;
     BasicProperties = properties;
     Body = body;
 }
开发者ID:ReactiveServices,项目名称:ReactiveServices.MessageBus.InSingleProcessMemory,代码行数:8,代码来源:InSingleProcessMemoryBus.cs

示例14: HydrateProperties

        internal void HydrateProperties(IBasicProperties properties)
        {
            properties.Persistent = false;

            foreach (var pair in _dictionary)
                if (!_reserverKeys.Contains(pair.Key))
                    properties.Headers.Add(pair.Key, pair.Value);
        }
开发者ID:emadb,项目名称:Carrot,代码行数:8,代码来源:HeaderCollection.cs

示例15: GenerateQueueItems

 //public static void Main(string[] args)
 //{
 //    var factory = new ConnectionFactory() { HostName = "localhost" };
 //    using (var connection = factory.CreateConnection())
 //    using (var channel = connection.CreateModel())
 //    {
 //        channel.QueueDeclare(queue: "task_queue",
 //                             durable: true,
 //                             exclusive: false,
 //                             autoDelete: false,
 //                             arguments: null);
 //        var properties = channel.CreateBasicProperties();
 //        properties.SetPersistent(true);
 //        for (var i = 0; i < 10; i++)
 //        {
 //            var text = String.Format("Message Numero {0}", i);
 //            var message = GetMessage(args, text);
 //            var body = Encoding.UTF8.GetBytes(message);
 //            GenerateQueueItems(args, channel, properties, body, message);
 //        }
 //    }
 //    Console.WriteLine(" Press [enter] to exit.");
 //    Console.ReadLine();
 //}
 private static void GenerateQueueItems(string[] args, IModel channel, IBasicProperties properties, byte[] body, string message)
 {
     channel.BasicPublish(exchange: "",
                          routingKey: "task_queue",
                          basicProperties: properties,
                          body: body);
     Console.WriteLine(" [x] Sent {0}", message);
 }
开发者ID:ryhoward,项目名称:RabbitMQMessagerTests,代码行数:32,代码来源:NewTask.cs


注:本文中的IBasicProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。