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


C# IModel.BasicGet方法代码示例

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


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

示例1: Exec

        // ReSharper disable ConditionIsAlwaysTrueOrFalse
        public static void Exec(bool durable, bool ack, IModel model, IConnection connection)
        {
            var queueName = "CSharpPublish" + (durable ? "Durable" : "NotDurable");
            if (!string.IsNullOrWhiteSpace(_overrideQueueName))
                queueName = _overrideQueueName;

            Console.WriteLine("Durability {0} enabled", durable ? "IS" : "is NOT");
            Console.WriteLine("ACK {0} enabled", ack ? "IS" : "is NOT");

            Console.WriteLine("Creating queue {0}...", queueName);
            model.QueueDeclare(queueName, durable, false, false, null);

            var msg = Encoding.UTF8.GetBytes("Hello from my PC !");
            var properties = new BasicProperties { DeliveryMode = (byte)(durable ? 2 : 1) };

            if (_publish)
            {
                for (int i = 0; i < _numMsgs; i++)
                    model.BasicPublish(string.Empty, queueName, properties, msg);

                Console.WriteLine("Published!");
            }

            uint msgs = 0;
            if (_receive)
            {
                Console.WriteLine("Reading...");
                var fromMac = false;
                while (connection.IsOpen)
                {
                    var result = model.BasicGet(queueName, ack == false);
                    if (result == null)
                        break;

                    if (msgs % 3144 == 0)
                        Console.WriteLine(msgs);

                    if (ack)
                        model.BasicAck(result.DeliveryTag, false);
                    var msgText = Encoding.UTF8.GetString(result.Body);
                    if (msgText.Contains("Mac"))
                        fromMac = true;
                    msgs++;
                }

                if (fromMac)
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                    Console.WriteLine("Received messages from the mac");
                    Console.ResetColor();
                }
            }
        }
开发者ID:xeb,项目名称:AmqpPresentation,代码行数:54,代码来源:PerformanceExample.cs

示例2: GetResult

        private static void GetResult(string queueName, IModel model)
        {
            var result = model.BasicGet(queueName, false);
            if (result == null)
            {
                Console.WriteLine("Nothing left!");
                return;
            }

            var msg = result.Body.Deserialize<SomeMessage>().ToJson();
            Console.WriteLine("Received {0}", msg);

            Console.WriteLine("ACK'ing reciept of msg {0}", result.DeliveryTag);
            model.BasicAck(result.DeliveryTag, false);

            // Recursively get the other results
            GetResult(queueName, model);
        }
开发者ID:xeb,项目名称:AmqpPresentation,代码行数:18,代码来源:ProtoBufExample.cs

示例3: GetResult

        private static void GetResult(string queueName, IModel model)
        {
            var result = model.BasicGet(queueName, false);
            if (result == null)
            {
                Console.WriteLine("Nothing left!");
                return;
            }

            var msg = Encoding.UTF8.GetString(result.Body);
            Console.WriteLine("Received {0}", msg);

            Console.WriteLine("ACK'ing reciept of msg {0}", result.DeliveryTag);
            model.BasicAck(result.DeliveryTag, false);

            // Recursively get the other results
            GetResult(queueName, model);
        }
开发者ID:xeb,项目名称:AmqpPresentation,代码行数:18,代码来源:HelloWorldExample.cs

示例4: _t_Elapsed

        void _t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            var connectionFactory = new ConnectionFactory();
             connection = connectionFactory.CreateConnection();
             channel = connection.CreateModel();
             channel.ExchangeDeclare("GIS", ExchangeType.Direct);
             channel.QueueDeclare("GIS", false, false, false, null);
             channel.QueueBind("GIS", "GIS", "PAUL");
             BasicGetResult result = channel.BasicGet("GIS", true);

             if (result != null)
               {
                msg = Encoding.UTF8.GetString(result.Body);
                MessageBox.Show(msg, "You've Got a Message!");
             //If set Message to send coords in form "35,-106" Next lines will draw points.
             string[] coords = msg.Split(',');
                float x = float.Parse(coords[0]);
                float y = float.Parse(coords[1]);
             Note fromRabbit = new Note("From RabbitMQ", new ESRI.ArcGISExplorer.Geometry.Point(y, x));
               ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Map.ChildItems.Add(fromRabbit);

            }
        }
开发者ID:jorik041,项目名称:ArcGIS-DesktopExplorer-AMQP,代码行数:23,代码来源:Extension.cs


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