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


C# MessageProperties类代码示例

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


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

示例1: Should_be_able_to_write_debug_properties

        public void Should_be_able_to_write_debug_properties()
        {
            const string expectedDebugProperties =
                "ContentType=content_type, ContentEncoding=content_encoding, " +
                "Headers=[key1=value1, key2=value2], DeliveryMode=10, Priority=3, CorrelationId=NULL, " +
                "ReplyTo=reply_to, Expiration=expiration, MessageId=message_id, Timestamp=123456, Type=type, " +
                "UserId=userid, AppId=app_id, ClusterId=cluster_id";

            var stringBuilder = new StringBuilder();
            var headers = new Dictionary<string, object>
                {
                    {"key1", "value1"},
                    {"key2", "value2"}
                };

            var properties = new MessageProperties
                {
                    AppId = "app_id",
                    ClusterId = "cluster_id",
                    ContentEncoding = "content_encoding",
                    ContentType = "content_type",
                    //CorrelationId = "correlation_id",
                    DeliveryMode = 10,
                    Expiration = "expiration",
                    Headers = headers,
                    MessageId = "message_id",
                    Priority = 3,
                    ReplyTo = "reply_to",
                    Timestamp = 123456,
                    Type = "type",
                    UserId = "userid",
                };

            properties.ToString().ShouldEqual(expectedDebugProperties);
        }
开发者ID:Maxwe11,项目名称:EasyNetQ,代码行数:35,代码来源:MessagePropertiesTests.cs

示例2: AmfMessageBase

        /// <summary>
        /// Constructor.
        /// </summary>
        protected AmfMessageBase()
        {
            _properties = new MessageProperties();

            //Make sure that there is no wrapping applied to this message
            _headers = new MessageHeaders(MessageVersion.None);
        }
开发者ID:artema,项目名称:DotAmf,代码行数:10,代码来源:AmfMessageBase.cs

示例3: OldSendMessages

        private void OldSendMessages(RabbitTemplate template)
        {
            IBasicProperties basicProperties = template.Execute<IBasicProperties>(delegate(IModel model)
                                                                                      {
                                                                                          return model.CreateBasicProperties();
                                                                                      });

            /*
             * System.ArgumentNullException: String reference not set to an instance of a String.
                Parameter name: s
                    at System.Text.Encoding.GetBytes(String s)
                    at RabbitMQ.Client.Impl.WireFormatting.WriteShortstr(NetworkBinaryWriter writer, String val)
             */
            IMessageProperties messageProperties = new MessageProperties(basicProperties);

            //write all short props
            messageProperties.ContentType = "text/plain";
            messageProperties.ContentEncoding = "UTF-8";
            messageProperties.CorrelationId = Encoding.UTF8.GetBytes("corr1");

            messageProperties.DeliveryMode = MessageDeliveryMode.PERSISTENT;
            messageProperties.Priority = 0;

            byte[] byteMessage = Encoding.UTF8.GetBytes("testing");
            template.Send("amq.direct", "foo", delegate
                                                   {
                                                       Message msg = new Message(byteMessage, messageProperties);
                                                       Console.WriteLine("sending...");
                                                       return msg;
                                                   });

            //template.Send("amq.direct", "foo", channel => new Message(Encoding.UTF8.GetBytes("testing"), messageProperties));
        }
开发者ID:moprise,项目名称:spring-net-amqp,代码行数:33,代码来源:ProducerExample.cs

示例4: PublishedMessageEvent

 public PublishedMessageEvent(string exchangeName, string routingKey, MessageProperties properties, byte[] body)
 {
     ExchangeName = exchangeName;
     RoutingKey = routingKey;
     Properties = properties;
     Body = body;
 }
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:7,代码来源:PublishedMessageEvent.cs

示例5: EchoHttpRequestMessageProperty

        public TestHttpRequestMessageProperty EchoHttpRequestMessageProperty()
        {
            object obj;
            MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
            if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
            {
                HttpRequestMessageProperty property = (HttpRequestMessageProperty)obj;
                if (property != null)
                {
                    TestHttpRequestMessageProperty testProperty = new TestHttpRequestMessageProperty();
                    testProperty.SuppressEntityBody = property.SuppressEntityBody;
                    testProperty.Method = property.Method;
                    testProperty.QueryString = property.QueryString;

                    WebHeaderCollection collection = property.Headers;
                    foreach (string s in collection.AllKeys)
                    {
                        string[] values = collection.GetValues(s);
                        testProperty.Headers.Add(s, String.Join(",", values));
                    }
                    return testProperty;
                }
            }

            return null;
        }
开发者ID:yxbdali,项目名称:wcf,代码行数:26,代码来源:WcfService.cs

示例6: AdwsRequestMsg

		protected AdwsRequestMsg(string instance)
		{
			this._messageProperties = new MessageProperties();
			this._messageHeaders = new MessageHeaders(this.Version, 7);
			this.Headers.Action = this.Action;
			this.Headers.Add(MessageHeader.CreateHeader("instance", "http://schemas.microsoft.com/2008/1/ActiveDirectory", instance));
		}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:AdwsRequestMsg.cs

示例7: AckEvent

 public AckEvent(MessageReceivedInfo info, MessageProperties properties, byte[] body , AckResult ackResult)
 {
     ReceivedInfo = info;
     Properties = properties;
     Body = body;
     AckResult = ackResult;
 }
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:7,代码来源:AckEvent.cs

示例8: GetMessagesFromQueue

        public IEnumerable<HosepipeMessage> GetMessagesFromQueue(QueueParameters parameters)
        {
            using (var connection = HosepipeConnection.FromParamters(parameters))
            using (var channel = connection.CreateModel())
            {
                try
                {
                    channel.QueueDeclarePassive(parameters.QueueName);
                }
                catch (OperationInterruptedException exception)
                {
                    Console.WriteLine(exception.Message);
                    yield break;
                }

                var count = 0;
                while (count++ < parameters.NumberOfMessagesToRetrieve)
                {
                    var basicGetResult = channel.BasicGet(parameters.QueueName, noAck: parameters.Purge);
                    if (basicGetResult == null) break; // no more messages on the queue

                    var properties = new MessageProperties(basicGetResult.BasicProperties);
                    var info = new MessageReceivedInfo(
                        "hosepipe",
                        basicGetResult.DeliveryTag,
                        basicGetResult.Redelivered,
                        basicGetResult.Exchange,
                        basicGetResult.RoutingKey,
                        parameters.QueueName);

                    yield return new HosepipeMessage(errorMessageSerializer.Serialize(basicGetResult.Body), properties, info);
                }
            }
        }
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:34,代码来源:QueueRetrieval.cs

示例9: ValidateMessagePropertyHeaders

        public Dictionary<string, string> ValidateMessagePropertyHeaders()
        {
            Dictionary<string, string> headerCollection = new Dictionary<string, string>();
            try
            {
                HttpRequestMessageProperty property;
                object obj;
                MessageProperties properties = new MessageProperties(OperationContext.Current.IncomingMessageProperties);
                if (properties.TryGetValue(HttpRequestMessageProperty.Name, out obj))
                {
                    property = obj as HttpRequestMessageProperty;
                    WebHeaderCollection collection = property.Headers;

                    string[] headers = collection.AllKeys;
                    foreach (string s in headers)
                    {
                        string[] values = collection.GetValues(s);
                        headerCollection.Add(s, String.Join(",", values));
                    }
                }
                else
                {
                    headerCollection.Add("ERROR", "No HttpRequestMessageProperty was found!");
                }
            }
            catch (Exception ex)
            {
                headerCollection.Add("ERROR", string.Format("An exception was thrown: {0}", ex.Message));
            }

            return headerCollection;
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:wcf,代码行数:32,代码来源:WcfService.cs

示例10: SendWithTemplate

        public void SendWithTemplate()
        {
            QpidTemplate template = InitializeAndCreateTemplate();

            IMessageProperties messageProperties = new MessageProperties();


            //write all short props
            messageProperties.ContentType = "text/plain";
            messageProperties.ContentEncoding = "UTF-8";
            messageProperties.CorrelationId = Encoding.UTF8.GetBytes("corr1");


            messageProperties.DeliveryMode = MessageDeliveryMode.PERSISTENT;
            messageProperties.Priority = 0;


            for (int i = 0; i < 10; i++)
            {
                template.Send("amq.direct", "routing_key", delegate
                {
                    Message msg = new Message(Encoding.UTF8.GetBytes("Message " + i), messageProperties);
                    Console.WriteLine("sending...");
                    return msg;
                });
            }
            template.Send("amq.direct", "routing_key", delegate
            {
                Message msg = new Message(Encoding.UTF8.GetBytes("That's all, folks!"), messageProperties);
                Console.WriteLine("sending...");
                return msg;
            });
            
        }
开发者ID:yonglehou,项目名称:spring-net-amqp,代码行数:34,代码来源:ProducerExample.cs

示例11: AppendTo

        public void AppendTo( MessageProperties messageProperties )
        {
            messageProperties.Type = messageType;

            if( alternativeTypes.Any() )
                messageProperties.Headers[ AlternativeMessageTypesHeaderKey ] = string.Join( AlternativeMessageTypeSeparator, alternativeTypes );
        }
开发者ID:KristofferV,项目名称:EasyNetQ,代码行数:7,代码来源:MessageTypeProperty.cs

示例12: SetUp

        public void SetUp()
        {
            postAckCallbackWasRun = false;

            //var logger = new ConsoleLogger();
            var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
            var consumerErrorStrategy = MockRepository.GenerateStub<IConsumerErrorStrategy>();

            handlerRunner = new HandlerRunner(logger, consumerErrorStrategy);

            Func<byte[], MessageProperties, MessageReceivedInfo, Task> userHandler = (body, properties, info) =>
                Task.Factory.StartNew(() =>
                    {
                        deliveredBody = body;
                        deliveredProperties = properties;
                        deliveredInfo = info;
                    });

            var consumer = MockRepository.GenerateStub<IBasicConsumer>();
            channel = MockRepository.GenerateStub<IModel>();
            consumer.Stub(x => x.Model).Return(channel).Repeat.Any();

            var context = new ConsumerExecutionContext(
                userHandler, messageInfo, messageProperties, messageBody, consumer);

            context.SetPostAckCallback(() => postAckCallbackWasRun = true);

            var autoResetEvent = new AutoResetEvent(false);
            ((HandlerRunner) handlerRunner).SynchronisationAction = () => autoResetEvent.Set();

            handlerRunner.InvokeUserMessageHandler(context);

            autoResetEvent.WaitOne(1000);
        }
开发者ID:stemarie,项目名称:EasyNetQ,代码行数:34,代码来源:When_a_user_handler_is_executed.cs

示例13: WriteSomeFiles

        public void WriteSomeFiles()
        {
            var directory = new DirectoryInfo(tempDirectory);
            foreach (var file in directory.EnumerateFiles())
            {
                file.Delete();
            }

            var properties = new MessageProperties();
            var info = Helper.CreateMessageRecievedInfo();
            var writer = new FileMessageWriter();
            var messages = new List<HosepipeMessage>
            {
                new HosepipeMessage("This is message one", properties, info),
                new HosepipeMessage("This is message two", properties, info),
                new HosepipeMessage("This is message three", properties, info)
            };

            var parameters = new QueueParameters
            {
                QueueName = "Queue EasyNetQ_Tests_TestAsyncRequestMessage:EasyNetQ_Tests_Messages",
                MessageFilePath = tempDirectory
            };

            writer.Write(messages, parameters);

            foreach (var file in directory.EnumerateFiles())
            {
                Console.Out.WriteLine("{0}", file.Name);
            }
        }
开发者ID:JohnEffo,项目名称:EasyNetQ,代码行数:31,代码来源:FileMessageWriterTests.cs

示例14: SetUp

        public void SetUp()
        {
            //var logger = new ConsoleLogger();
            var logger = MockRepository.GenerateStub<IEasyNetQLogger>();
            var consumerErrorStrategy = MockRepository.GenerateStub<IConsumerErrorStrategy>();
            var eventBus = new EventBus();

            handlerRunner = new HandlerRunner(logger, consumerErrorStrategy, eventBus);

            Func<byte[], MessageProperties, MessageReceivedInfo, Task> userHandler = (body, properties, info) => 
                Task.Factory.StartNew(() =>
                    {
                        deliveredBody = body;
                        deliveredProperties = properties;
                        deliveredInfo = info;
                    });

            var consumer = MockRepository.GenerateStub<IBasicConsumer>();
            channel = MockRepository.GenerateStub<IModel>();
            consumer.Stub(x => x.Model).Return(channel).Repeat.Any();

            var context = new ConsumerExecutionContext(
                userHandler, messageInfo, messageProperties, messageBody, consumer);

            var autoResetEvent = new AutoResetEvent(false);
            eventBus.Subscribe<AckEvent>(x => autoResetEvent.Set());

            handlerRunner.InvokeUserMessageHandler(context);

            autoResetEvent.WaitOne(1000);
        }
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:31,代码来源:When_a_user_handler_is_executed.cs

示例15: AddOrReplaceInMessageProperties

 public void AddOrReplaceInMessageProperties(MessageProperties properties)
 {
     if (properties == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
     }
     properties["ContextMessageProperty"] = this;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:ContextMessageProperty.cs


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