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


C# IModel.Close方法代码示例

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


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

示例1: CloseChannel

 public static void CloseChannel(IModel channel)
 {
     if (channel != null)
     {
         try
         {
             channel.Close();
         }
         //TODO should this really be trace level?
         catch (Exception ex)
         {
             logger.Trace("Unexpected exception on closing RabbitMQ Channel", ex);
         }
     }
 }
开发者ID:moprise,项目名称:spring-net-amqp,代码行数:15,代码来源:RabbitUtils.cs

示例2: CloseChannel

 /// <summary>
 /// Close the channel.
 /// </summary>
 /// <param name="channel">
 /// The channel.
 /// </param>
 public static void CloseChannel(IModel channel)
 {
     if (channel != null && channel.IsOpen)
     {
         try
         {
             channel.Close();
         }
         catch (IOException ioex)
         {
             logger.Debug("Could not close RabbitMQ Channel", ioex);
         }
         catch (Exception ex)
         {
             logger.Debug("Unexpected exception on closing RabbitMQ Channel", ex);
         }
     }
 }
开发者ID:DonMcRae,项目名称:spring-net-amqp,代码行数:24,代码来源:RabbitUtils.cs

示例3: receive

        public String receive(String queueName)
        {
            Console.WriteLine(queueName);
            Console.WriteLine("In RabbitMQ.receive");
            string messageReceived = "";
            Console.WriteLine("connectionFactory : " + connectionFactory);

            using (connection = connectionFactory.CreateConnection())
            {
                Console.WriteLine("connection : " + connection);
                using (channel = connection.CreateModel())
                {
                    Console.WriteLine("channel : " + channel);
                    channel.QueueDeclare(queue: queueName,
                                            durable: false,
                                            exclusive: false,
                                            autoDelete: false,
                                            arguments: null);
                    EventingBasicConsumer consumer = new EventingBasicConsumer(channel);
                    Console.WriteLine("Requesting message");
                    consumer.Received += (Model, ea) =>
                    {
                        var body = ea.Body;
                        messageReceived = Encoding.UTF8.GetString(body);
                        Console.WriteLine("Message received : " + messageReceived);
                    };

                    channel.BasicConsume(queue: queueName,
                        noAck: true,
                        consumer: consumer);

                    Console.WriteLine("Waiting for message ...");

                    while (messageReceived == "") { } //menunggu hingga menerima pesan

                    channel.Close();
                    connection.Close();
                    return messageReceived;
                }

            }
        }
开发者ID:eripahle,项目名称:SoundRecognition,代码行数:42,代码来源:RabbitMQ.cs

示例4: CloseModel

 public void CloseModel(IModel model, TimeSpan timeout)
 {
     model.Close((ushort) CurrentVersion.StatusCodes.Ok, "Goodbye");
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:4,代码来源:ConnectionManager.cs

示例5: ShutdownAmqp

        private void ShutdownAmqp(IConnection connection, IModel model, ShutdownEventArgs reason)
        {
            try
            {
                if (connection != null)
                {
                    connection.ConnectionShutdown -= ShutdownAmqp;
                    connection.AutoClose = true;
                }

                if (model != null)
                {
                    model.ModelShutdown -= this.OnModelShutdown;
                    this.Debug("closing amqp model. {0}.", reason);
                    model.Close(Constants.ReplySuccess, "closing rabbitmq appender, shutting down logging");
                    model.Dispose();

                    this.Debug("amqp model closed.");
                }
            }
            catch (Exception e)
            {
                ErrorHandler.Error("could not close model", e);
            }
        }
开发者ID:TarheadStudio,项目名称:log4net.RabbitMQ,代码行数:25,代码来源:RabbitMQAppenderBase.cs

示例6: ConsumeAsync

        private async void ConsumeAsync(IConnection connection)
        {
            await Task.Factory.StartNew(() =>
            {
                //Create a channel for the consuming thread
                using (requestChannel = connection.CreateModel())
                {
                    //Declare the exchange
                    requestChannel.ExchangeDeclare(ExchangeName, "topic");

                    //Decalre a temporary queue and bind it to the requests being sent to the exchange
                    var queueName = requestChannel.QueueDeclare().QueueName;
                    requestChannel.QueueBind(queueName, ExchangeName, RequestQueue);

                    //Create a consumer to get the request messages
                    var consumer = new QueueingBasicConsumer(requestChannel);
                    requestChannel.BasicConsume(queueName, true, consumer);
                    
                    //Consume message queue
                    while (run)
                    {
                        BasicDeliverEventArgs ea;
                        if (!consumer.Queue.Dequeue(1000, out ea))
                            continue;

                        var isin = Encoding.UTF8.GetString(ea.Body);

                        //Check ISIN does not already exist - produce prices for the requested ISIN
                        if (!dataChannels.ContainsKey(isin))
                            ProduceAsync(connection, isin);
                    }

                    requestChannel.Close();
                }
            },
            TaskCreationOptions.LongRunning);

            Console.WriteLine("Stopped consuming requests");
        }
开发者ID:dave111,项目名称:MockBondDemo,代码行数:39,代码来源:Producer.cs


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