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


C# IModel.CreateBasicProperties方法代码示例

本文整理汇总了C#中IModel.CreateBasicProperties方法的典型用法代码示例。如果您正苦于以下问题:C# IModel.CreateBasicProperties方法的具体用法?C# IModel.CreateBasicProperties怎么用?C# IModel.CreateBasicProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IModel的用法示例。


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

示例1: Create

 public virtual IBasicProperties Create(IModel channel, MessageProperties properties)
 {
     var basicProperties = channel.CreateBasicProperties();
     if(!string.IsNullOrWhiteSpace(properties.MessageId))
     {
         basicProperties.MessageId = properties.MessageId;
     }
     if(!string.IsNullOrWhiteSpace(properties.CorrelationId))
     {
         basicProperties.CorrelationId = properties.CorrelationId;
     }
     if(!string.IsNullOrWhiteSpace(properties.ContentType))
     {
         basicProperties.ContentType = properties.ContentType;
     }
     if(!string.IsNullOrWhiteSpace(properties.ContentEncoding))
     {
         basicProperties.ContentEncoding = properties.ContentEncoding;
     }
     basicProperties.DeliveryMode = (byte) properties.DeliveryMode;
     if(properties.Headers.Keys.Any())
     {
         basicProperties.Headers = new Dictionary<object, object>();
         foreach(var key in properties.Headers.Keys)
         {
             basicProperties.Headers.Add(key, properties.Headers[key]);
         }
     }
     return basicProperties;
 }
开发者ID:swmal,项目名称:RabbitMQUtil,代码行数:30,代码来源:BasicPropertiesFactory.cs

示例2: CallService

 private void CallService(IModel channel, string queueName)
 {
     var properties = channel.CreateBasicProperties();
     properties.ReplyTo = queueName;
     properties.CorrelationId = (++correlationId).ToString();
     channel.BasicPublish("", Constants.RpcQueueName, properties, Encoding.UTF8.GetBytes(n.ToString()));
 }
开发者ID:simoneb,项目名称:Roger,代码行数:7,代码来源:FibonacciClient.cs

示例3: SendMessage

        void SendMessage(TransportMessage message, SendOptions sendOptions, IModel channel)
        {

            var destination = sendOptions.Destination;

            string callbackAddress;

            if (sendOptions.GetType().FullName.EndsWith("ReplyOptions") &&
                message.Headers.TryGetValue(CallbackHeaderKey, out callbackAddress))
            {
                destination = Address.Parse(callbackAddress);
            }

            //set our callback address
            if (!string.IsNullOrEmpty(CallbackQueue))
            {
                message.Headers[CallbackHeaderKey] = CallbackQueue;     
            }
           
            var properties = channel.CreateBasicProperties();

            RabbitMqTransportMessageExtensions.FillRabbitMqProperties(message, sendOptions, properties);

            RoutingTopology.Send(channel, destination, message, properties);
        }
开发者ID:MyDealerLot,项目名称:NServiceBus.RabbitMQ,代码行数:25,代码来源:RabbitMqMessageSender.cs

示例4: CreatePropertiesFactory

        private Func<RogerEndpoint, IBasicProperties> CreatePropertiesFactory(IModel model,
            IIdGenerator idGenerator,
            IMessageTypeResolver messageTypeResolver,
            IMessageSerializer serializer,
            ISequenceGenerator sequenceGenerator)
        {
            var properties = model.CreateBasicProperties();

            properties.MessageId = idGenerator.Next();
            properties.Type = messageTypeResolver.Unresolve(messageType);
            properties.ContentType = serializer.ContentType;

            properties.Headers = new Hashtable
            {
                {Headers.Sequence, BitConverter.GetBytes(sequenceGenerator.Next(messageType))}
            };

            if (persistent)
                properties.DeliveryMode = 2;

            FillAdditionalProperties(properties, idGenerator);

            return endpoint =>
            {
                properties.ReplyTo = endpoint;
                return properties;
            };
        }
开发者ID:bibendus,项目名称:Roger,代码行数:28,代码来源:AbstractDeliveryFactory.cs

示例5: CreateDefaultProperties

        public static IBasicProperties CreateDefaultProperties(IModel model) {
            var properties = model.CreateBasicProperties();

            properties.SetPersistent(true);
            properties.ContentType = "application/json";
            properties.ContentEncoding = "UTF-8";

            return properties;
        }
开发者ID:yonglehou,项目名称:Daishi.AMQP,代码行数:9,代码来源:RabbitMQProperties.cs

示例6: SendDurableMessageToDurableQueue

        private static void SendDurableMessageToDurableQueue(IModel model)
        {
            IBasicProperties basicProperties = model.CreateBasicProperties();
            basicProperties.SetPersistent(true);
            byte[] payload = Encoding.UTF8.GetBytes("This is a persistent message from Visual Studio");
            PublicationAddress address = new PublicationAddress(ExchangeType.Topic, "DurableExchange", "durable");

            model.BasicPublish(address, basicProperties, payload);
        }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:9,代码来源:Program.cs

示例7: BasicMessageBuilder

        ///<summary>Construct an instance ready for writing.</summary>
        public BasicMessageBuilder(IModel model, int initialAccumulatorSize) {
            m_properties = model.CreateBasicProperties();
            m_accumulator = new MemoryStream(initialAccumulatorSize);

            string contentType = GetDefaultContentType();
            if (contentType != null) {
                Properties.ContentType = contentType;
            }
        }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:10,代码来源:BasicMessageBuilder.cs

示例8: GetBasicProperties

        private static IBasicProperties GetBasicProperties(string messageUri, IModel channel)
        {
            var bp = channel.CreateBasicProperties();
            bp.ContentType = "application/skutt";
            bp.SetPersistent(true);
            bp.CorrelationId = Guid.NewGuid().ToString();
            bp.Type = messageUri;

            return bp;
        }
开发者ID:kjnilsson,项目名称:Skutt,代码行数:10,代码来源:PublishTopicChannel.cs

示例9: Publish

        public void Publish(IModel model, string queue, string message)
        {
            var properties = model.CreateBasicProperties();
            properties.SetPersistent(true);

            var nextPublishSeqNo = model.NextPublishSeqNo;
            Console.Out.WriteLine("Published seq no = {0}", nextPublishSeqNo);

            model.BasicPublish("", queue, properties, Encoding.UTF8.GetBytes(message));
        }
开发者ID:richard-green,项目名称:EasyNetQ,代码行数:10,代码来源:PublisherConfirms.cs

示例10: TextParameters

 public static MessageParameters TextParameters(IModel model, string type, string messageId,
     DateTime timestamp)
 {
     IBasicProperties properties = model.CreateBasicProperties();
     properties.ContentType = "text/plain";
     properties.DeliveryMode = 1;
     properties.MessageId = messageId;
     properties.Timestamp = new AmqpTimestamp(timestamp.Ticks);
     properties.Type = type;
     return new MessageParameters(properties);
 }
开发者ID:ZhangColin,项目名称:IDDD_Samples_by_Colin,代码行数:11,代码来源:MessageParameters.cs

示例11: ScheduleTask

        private static void ScheduleTask(string message, IModel channel)
        {
            message = (!String.IsNullOrEmpty(message))
                                 ? message
                                 : "Hello World!";
            byte[] body = System.Text.Encoding.UTF8.GetBytes(message);

            IBasicProperties properties = channel.CreateBasicProperties();
            properties.DeliveryMode = 2;

            channel.BasicPublish("", "task_queue", properties, body);
            Console.WriteLine(" [x] Sent {0}", message);
        }
开发者ID:ZS,项目名称:QueueTest,代码行数:13,代码来源:Program.cs

示例12: RunBadMessageDemo

 private static void RunBadMessageDemo(IModel model)
 {
     Console.WriteLine("Enter your message. Quit with 'q'.");
     while (true)
     {
         string message = Console.ReadLine();
         if (message.ToLower() == "q") break;
         IBasicProperties basicProperties = model.CreateBasicProperties();
         basicProperties.SetPersistent(true);
         byte[] messageBuffer = Encoding.UTF8.GetBytes(message);
         model.BasicPublish("", RabbitMqService.BadMessageBufferedQueue, basicProperties, messageBuffer);
     }
 }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:13,代码来源:Program.cs

示例13: DemoQueue

        // Sends a message to a queue to be handled by available worker
        static void DemoQueue(IModel model)
        {
            model.QueueDeclare("myqueue", true, false, false, null);

            var properties = model.CreateBasicProperties();
            properties.SetPersistent(true);

            while (true)
            {
                var message = Console.ReadLine();
                var body = Encoding.UTF8.GetBytes(message);
                model.BasicPublish("", "myqueue", properties, body);
            }
        }
开发者ID:mimipaskova,项目名称:Azure-Tech-Entrepreneurship-Course,代码行数:15,代码来源:Program.cs

示例14: RunChunkedMessageExample

        private static void RunChunkedMessageExample(IModel model)
        {
            string filePath = @"c:\large_file.txt";
            int chunkSize = 4096;

            while (true)
            {
                ConsoleKeyInfo keyInfo = Console.ReadKey();
                if (keyInfo.Key == ConsoleKey.Enter)
                {
                    Console.WriteLine("Starting file read operation...");
                    FileStream fileStream = File.OpenRead(filePath);
                    StreamReader streamReader = new StreamReader(fileStream);
                    int remainingFileSize = Convert.ToInt32(fileStream.Length);
                    int totalFileSize = Convert.ToInt32(fileStream.Length);
                    bool finished = false;
                    string randomFileName = string.Concat("large_chunked_file_", Guid.NewGuid(), ".txt");

                    byte[] buffer;
                    while (true)
                    {
                        if (remainingFileSize <= 0) break;
                        int read = 0;
                        if (remainingFileSize > chunkSize)
                        {
                            buffer = new byte[chunkSize];
                            read = fileStream.Read(buffer, 0, chunkSize);
                        }
                        else
                        {
                            buffer = new byte[remainingFileSize];
                            read = fileStream.Read(buffer, 0, remainingFileSize);
                            finished = true;
                        }

                        IBasicProperties basicProperties = model.CreateBasicProperties();
                        basicProperties.SetPersistent(true);
                        basicProperties.Headers = new Dictionary<string, object>();
                        basicProperties.Headers.Add("output-file", randomFileName);
                        basicProperties.Headers.Add("finished", finished);

                        model.BasicPublish("", RabbitMqService.ChunkedMessageBufferedQueue, basicProperties, buffer);
                        remainingFileSize -= read;
                    }
                    Console.WriteLine("Chunks complete.");
                }
            }
        }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:48,代码来源:Program.cs

示例15: RunBufferedMessageExample

 private static void RunBufferedMessageExample(IModel model)
 {
     string filePath = @"c:\large_file.txt";
     ConsoleKeyInfo keyInfo = Console.ReadKey();
     while (true)
     {
         if (keyInfo.Key == ConsoleKey.Enter)
         {
             IBasicProperties basicProperties = model.CreateBasicProperties();
             basicProperties.SetPersistent(true);
             byte[] fileContents = File.ReadAllBytes(filePath);
             model.BasicPublish("", RabbitMqService.LargeMessageBufferedQueue, basicProperties, fileContents);
         }
         keyInfo = Console.ReadKey();
     }
 }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:16,代码来源:Program.cs


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