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


C# IModel.BasicQos方法代码示例

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


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

示例1: DeclareQueue

		protected virtual void DeclareQueue(IModel channel)
		{
			if (this.DispatchOnly)
				return;

			var declarationArgs = new Dictionary<string, object>();
			if (this.DeadLetterExchange != null)
				declarationArgs[DeadLetterExchangeDeclaration] = this.DeadLetterExchange.ExchangeName;

			if (this.Clustered)
				declarationArgs[ClusteredQueueDeclaration] = ReplicateToAllNodes;

			var inputQueue = this.InputQueue;
			if (this.RandomInputQueue)
				inputQueue = string.Empty;

			var declaration = channel.QueueDeclare(
				inputQueue, this.DurableQueue, this.ExclusiveQueue, this.AutoDelete, declarationArgs);

			if (declaration != null)
				this.InputQueue = declaration.QueueName;

			if (!this.ReturnAddressSpecified)
				this.ReturnAddress = new Uri(DefaultReturnAddressFormat.FormatWith(this.InputQueue));

			if (this.PurgeOnStartup)
				channel.QueuePurge(this.InputQueue);

			channel.BasicQos(0, (ushort)this.ChannelBuffer, false);
		}
开发者ID:yonglehou,项目名称:NanoMessageBus,代码行数:30,代码来源:RabbitChannelGroupConfiguration.cs

示例2: ReceiveDotNetObjects

        private static void ReceiveDotNetObjects(IModel model)
        {
            model.BasicQos(0, 1, false);
            QueueingBasicConsumer consumer = new QueueingBasicConsumer(model);
            model.BasicConsume(CommonService.DotNetObjectQueueName, false, consumer);
            while (true)
            {

                BasicDeliverEventArgs deliveryArguments = consumer.Queue.Dequeue() as BasicDeliverEventArgs;
                string objectType = deliveryArguments.BasicProperties.Type;
                Type t = Type.GetType(objectType);
                String jsonified = Encoding.UTF8.GetString(deliveryArguments.Body);
                object rawObject = JsonConvert.DeserializeObject(jsonified, t);
                Console.WriteLine("Object type: {0}", objectType);

                if (rawObject.GetType() == typeof(Customer))
                {
                    Customer customer = rawObject as Customer;
                    Console.WriteLine("Customer name: {0}", customer.Name);
                }
                else if (rawObject.GetType() == typeof(NewCustomer))
                {
                    NewCustomer newCustomer = rawObject as NewCustomer;
                    Console.WriteLine("NewCustomer name: {0}", newCustomer.Name);
                }
                model.BasicAck(deliveryArguments.DeliveryTag, false);
            }
        }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:28,代码来源:Program.cs

示例3: MessageQueue

        //private string _exchange;
        //_________________________________________________________________________________________________
        // Constructor, it initializes the message queue to just consume messages
        public MessageQueue(string server, string exchange, string queue)
        {
            try
            {
                ConnectionFactory factory;

                /*server = (server == null) ? ConfigurationManager.AppSettings["queueServer"] : server;
                _queueName = (queue == null) ? ConfigurationManager.AppSettings["queueName"] : queue;*/
                _queueName = queue;

                factory = new ConnectionFactory();
                factory.UserName = "guest";
                factory.Password = "guest";
                factory.Port = 5672; // default is 5672
                factory.VirtualHost = "/"; // default is "/"
                factory.HostName = server;

                _conn = factory.CreateConnection();
                _channel = _conn.CreateModel();

                _channel.QueueDeclare(_queueName, true, false, false, null); // it will save to the disk

                _channel.BasicQos(0, 1, false); // get just 1 message

                // We configure the class to have a event consumer
                _consumer = new QueueingBasicConsumer(_channel);
                _channel.BasicConsume(_queueName, false, _consumer);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
开发者ID:B3RTG,项目名称:IMSTemplates,代码行数:36,代码来源:MessageQueue.cs

示例4: ConfigureQos

		protected void ConfigureQos(IModel channel, ushort prefetchCount)
		{
			channel.BasicQos(
				prefetchSize: 0,
				prefetchCount: prefetchCount,
				global: false
			);
		}
开发者ID:brettnagy,项目名称:RawRabbit,代码行数:8,代码来源:QueueingBaiscConsumerFactory.cs

示例5: ConfigureQueueChannel

        private void ConfigureQueueChannel(IModel channel)
        {
            channel.QueueDeclare(queue: _defaultQueue,
                                 durable: true,
                                 exclusive: false,
                                 autoDelete: false,
                                 arguments: null);

            channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);
            Console.WriteLine("[*] Waiting for messages...");
        }
开发者ID:mvelasquezbarnuevo,项目名称:JobProcessor,代码行数:11,代码来源:Worker.cs

示例6: Consumer

 public Consumer(string hostName, string queueName)
 {
     QueueName = queueName;
     ConnectionFactory connectionFactory = new ConnectionFactory();
     connectionFactory.HostName = hostName;
     Connection = connectionFactory.CreateConnection();
     Model = Connection.CreateModel();
     Model.BasicQos(0,1,false);
     bool durable = true;
     Model.QueueDeclare(QueueName, durable, false, false, null);
 }
开发者ID:DanielSpalding,项目名称:getting-started-with-rabbitmq,代码行数:11,代码来源:Consumer.cs

示例7: CreateConnection

 public void CreateConnection()
 {
     _factory = new ConnectionFactory { HostName = "localhost", UserName = "guest", Password = "guest" };
     _connection = _factory.CreateConnection();
     _channel = _connection.CreateModel();
     _channel.QueueDeclare("rpc_queue", false, false, false, null);
     _channel.BasicQos(0, 1, false);
     _consumer = new QueueingBasicConsumer(_channel);
     _channel.BasicConsume("rpc_queue", false, _consumer);
     _rnd = new Random();
 }
开发者ID:FantasticFiasco,项目名称:sandbox,代码行数:11,代码来源:RabbitMQConsumer.cs

示例8: Declare

		public virtual void Declare(IModel channel)
		{
			if (Name.StartsWith("amq.", StringComparison.OrdinalIgnoreCase) == false)
				channel.QueueDeclare(
					Name,
					Durable,
					Exclusive,
					AutoDelete,
					Args);

			channel.BasicQos(0, 1, false);
		}
开发者ID:Pondidum,项目名称:RabbitHarness,代码行数:12,代码来源:QueueDefinition.cs

示例9: ConfigureQos

 protected void ConfigureQos(IModel channel, ushort prefetchCount)
 {
     /*
         QoS is per consumer on channel. If ChannelFactory is used,
         we might get a new channel than the one the consumer is
         we are configuring.
     */
     _logger.LogDebug($"Setting QoS\n  Prefetch Size: 0\n  Prefetch Count: {prefetchCount}\n  global: false");
     channel.BasicQos(
             prefetchSize: 0, //TODO : what is this?
             prefetchCount: prefetchCount,
             global: false // https://www.rabbitmq.com/consumer-prefetch.html
         );
 }
开发者ID:Originalutter,项目名称:RawRabbit,代码行数:14,代码来源:OperatorBase.cs

示例10: ReceiveBufferedMessages

 private static void ReceiveBufferedMessages(IModel model)
 {
     model.BasicQos(0, 1, false);
     QueueingBasicConsumer consumer = new QueueingBasicConsumer(model);
     model.BasicConsume(RabbitMqService.LargeMessageBufferedQueue, false, consumer);
     while (true)
     {
         BasicDeliverEventArgs deliveryArguments = consumer.Queue.Dequeue() as BasicDeliverEventArgs;
         byte[] messageContents = deliveryArguments.Body;
         string randomFileName = string.Concat(@"c:\large_file_from_rabbit_", Guid.NewGuid(), ".txt");
         Console.WriteLine("Received message, will save it to {0}", randomFileName);
         File.WriteAllBytes(randomFileName, messageContents);
         model.BasicAck(deliveryArguments.DeliveryTag, false);
     }
 }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:15,代码来源:Program.cs

示例11: DemoQueue

        // This shows handling messages from a queue - each message is handled by a single worker
        static void DemoQueue(IModel model)
        {
            model.QueueDeclare("myqueue", true, false, false, null);
            model.BasicQos(0, 1, false);

            var consumer = new QueueingBasicConsumer(model);
            model.BasicConsume("myqueue", false, consumer);

            while (true)
            {
                var message = consumer.Queue.Dequeue();
                DoWork(message);
                // Since BasicConsume is called with noAck: false, we need to manually let Rabbit know that the message was handled
                model.BasicAck(message.DeliveryTag, false);
            }
        }
开发者ID:mimipaskova,项目名称:Azure-Tech-Entrepreneurship-Course,代码行数:17,代码来源:Program.cs

示例12: GetUserRegisteredConsumer

        private static QueueingBasicConsumer GetUserRegisteredConsumer(out IModel channel)
        {
            var mqname = "UserRegisterWatcher";
            channel = _mqpool.GetMQChannel(mqname);

            var exchangeAndQueueName = Utilities.GetExchangeAndQueueNameOfUserRegistered();

            channel.ExchangeDeclare(exchangeAndQueueName.Item1, ExchangeType.Direct, true, false, null);
            channel.QueueDeclare(exchangeAndQueueName.Item2, true, false, false, null);
            channel.QueueBind(exchangeAndQueueName.Item2, exchangeAndQueueName.Item1, string.Empty);
            channel.BasicQos(0, 1, false);

            var consumer = new QueueingBasicConsumer(channel);
            channel.BasicConsume(exchangeAndQueueName.Item2, false, consumer);

            return consumer;
        }
开发者ID:timfun,项目名称:DotPay,代码行数:17,代码来源:UserRegisterWatcher.cs

示例13: LauncherServerSendRequestToTShock

        public LauncherServerSendRequestToTShock()
        {
            channel = OverallInformations.conn.CreateModel();
            channel.ExchangeDeclare(exchange: OverallInformations.LauncherServerTShockExchange, type: "direct", durable: false, autoDelete: true, arguments: null);
            replyQueueOk = channel.QueueDeclare();
            channel.QueueBind(queue: replyQueueOk.QueueName, exchange: OverallInformations.LauncherServerTShockExchange, routingKey: replyQueueOk.QueueName, arguments: null);
            channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);
            consumer = new EventingBasicConsumer(channel);

            consumer.Received += (model, _ea) =>
            {
                ea = _ea;
                LauncherReadyEvent.Set();
            };

            channel.BasicConsume(queue: replyQueueOk.QueueName, noAck: true, consumer: consumer);
        }
开发者ID:truongchauhien,项目名称:Terraria-Launcher,代码行数:17,代码来源:LauncherServerSendRequestToTShock.cs

示例14: ReceiveSerialisationMessages

 private static void ReceiveSerialisationMessages(IModel model)
 {
     model.BasicQos(0, 1, false);
     QueueingBasicConsumer consumer = new QueueingBasicConsumer(model);
     model.BasicConsume(CommonService.SerialisationQueueName, false, consumer);
     while (true)
     {
         BasicDeliverEventArgs deliveryArguments = consumer.Queue.Dequeue() as BasicDeliverEventArgs;
         string contentType = deliveryArguments.BasicProperties.ContentType;
         string objectType = deliveryArguments.BasicProperties.Type;
         String jsonified = Encoding.UTF8.GetString(deliveryArguments.Body);
         Customer customer = JsonConvert.DeserializeObject<Customer>(jsonified);
         Console.WriteLine("Pure json: {0}", jsonified);
         Console.WriteLine("Customer name: {0}", customer.Name);
         model.BasicAck(deliveryArguments.DeliveryTag, false);
     }
 }
开发者ID:JamisonWhite,项目名称:rabbitmqdotnet,代码行数:17,代码来源:Program.cs

示例15: GetAddressGeneratorConsumer

        private static QueueingBasicConsumer GetAddressGeneratorConsumer(CurrencyType currency, out IModel channel)
        {
            var mqname = "NXTAccountGenerator";
            channel = _mqpool.GetMQChannel(mqname);

            var exchangeAndQueueName = Utilities.GenerateExchangeAndQueueNameOfGenerateNewAddress(currency);

            channel.ExchangeDeclare(exchangeAndQueueName.Item1, ExchangeType.Direct, true, false, null);
            channel.QueueDeclare(exchangeAndQueueName.Item2, true, false, false, null);
            channel.QueueBind(exchangeAndQueueName.Item2, exchangeAndQueueName.Item1, string.Empty);
            channel.BasicQos(0, 1, false);

            var consumer = new QueueingBasicConsumer(channel);
            channel.BasicConsume(exchangeAndQueueName.Item2, false, consumer);

            return consumer;
        }
开发者ID:timfun,项目名称:DotPay,代码行数:17,代码来源:NXTAccountGenerator.cs


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