• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IBasicProperties类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetEnvelope

 public RabbitEnvelope GetEnvelope( IBasicProperties basicProperties )
 {
     var messageTypeBuffer = (byte[]) basicProperties.Headers["MessageType"];
     var messageTypeName = Encoding.UTF8.GetString( messageTypeBuffer );
     var messageType = Type.GetType( messageTypeName );
     var envelopeType = typeof( RabbitEnvelope<> ).MakeGenericType( messageType );
     return Activator.CreateInstance( envelopeType ) as RabbitEnvelope;
 }
开发者ID:cmgator,项目名称:Symbiote,代码行数:8,代码来源:RabbitQueueListener.cs


示例17: ExecuteSubscriptionMessageHandler

        protected override void ExecuteSubscriptionMessageHandler(IBasicProperties properties, object message, Dictionary<string, string> headers)
        {
            var messageType = message.GetType();

            InSingleProcessMemoryAuthorizer.Verify(Operation, messageType, message, headers);

            base.ExecuteSubscriptionMessageHandler(properties, message, headers);
        }
开发者ID:ReactiveServices,项目名称:ReactiveServices.MessageBus.InSingleProcessMemory,代码行数:8,代码来源:InSingleProcessMemoryAuthorizedBuses.cs


示例18: Serialize

		public byte[] Serialize(object instance, IBasicProperties prop)
		{
			var buffer = new byte[16];
			_number.GetNonZeroBytes(buffer);

			_byte2instance[buffer] = instance;

			return buffer;
		}
开发者ID:clearctvm,项目名称:Castle.RabbitMq,代码行数:9,代码来源:StubRabbitSerializer.cs


示例19: DequeueResult

 public DequeueResult(ulong deliveryTag, bool redelivered, string exchange, string routingKey, uint messageCount, IBasicProperties basicProperties, Stream body)
 {
     DeliveryTag = deliveryTag;
     Redelivered = redelivered;
     Exchange = exchange;
     RoutingKey = routingKey;
     MessageCount = messageCount;
     BasicProperties = basicProperties;
     Body = body;
 }
开发者ID:hjb417,项目名称:rabbitmq-wcf-transports,代码行数:10,代码来源:DequeueResult.cs


示例20: MessageContext

 public MessageContext(IBasicProperties basicProperties)
 {
     MessageId = basicProperties.MessageId;
     CorrelationId = basicProperties.CorrelationId;
     ReplyTo = basicProperties.ReplyTo;
     Type = basicProperties.Type;
     ContentType = basicProperties.ContentType;
     ContentEncoding = basicProperties.ContentEncoding;
     Headers = basicProperties.Headers;
 }
开发者ID:RagtimeWilly,项目名称:WhiteRabbit,代码行数:10,代码来源:MessageContext.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IBasicRobot类代码示例发布时间:2022-05-24
下一篇:
C# IBasicConsumer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap