• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IBasicConsumer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: rate_limit_notify

 private static void rate_limit_notify(IBasicConsumer consumer,
                                       BasicDeliverEventArgs eargs) {
     
     string[] EMAIL_RECIPS = new string[] {"[email protected]"};
     
     IBasicProperties msg_props = eargs.BasicProperties;
     String msg_body = Encoding.ASCII.GetString(eargs.Body);
     
     //#/(ascdn.4) Decode our message from JSON
     msg_body = JsonConvert.DeserializeObject
                            <string>(msg_body);
     
     //#/(ascdn.5) Transmit e-mail to SMTP server
     send_mail(EMAIL_RECIPS,
               "RATE LIMIT ALERT!",
               msg_body);
     
     Console.WriteLine("Sent alert via e-mail! Alert Text: " +
                       msg_body + " Recipients: " +
                       string.Join(",", EMAIL_RECIPS));
     
     //#/(ascdn.6) Acknowledge the message
     consumer.Model.BasicAck(eargs.DeliveryTag,
                             false);
 }
开发者ID:FFng,项目名称:sourcecode,代码行数:25,代码来源:alerting_server_consumer.cs


示例2: BasicConsume

 /// <summary>Start a Basic content-class consumer.</summary>
 public static string BasicConsume(this IModel model, string queue,
     bool autoAck,
     string consumerTag,
     IBasicConsumer consumer)
 {
     return model.BasicConsume(queue, autoAck, consumerTag, false, false, null, consumer);
 }
开发者ID:rabbitmq,项目名称:rabbitmq-dotnet-client,代码行数:8,代码来源:IModelExtensions.cs


示例3: HandleMessage

        public virtual void HandleMessage(IBasicConsumer consumer, BasicDeliverEventArgs eventArg)
        {
            var completionTask = _jobFactory(eventArg);
            completionTask.ContinueWith(task =>
            {
                try
                {
                    if (task.IsFaulted)
                    {
                        HandleError(consumer, eventArg, task.Exception);
                    }
                }
                catch (Exception ex)
                {
                    _watcher.Error(ex);
                }
                finally
                {
                    // Broadcast msgs
                    AfterHandlingMessage(consumer, eventArg);

                    //NOTE: Only this way, the new event to interupt other consumers will override previous resume event
                    if (HandlingComplete != null)
                    {
                        // Release pool + DoAck
                        HandlingComplete(eventArg);
                    }
                }
            });
        }
开发者ID:brett--anderson,项目名称:Burrow.NET,代码行数:30,代码来源:DefaultMessageHandler.cs


示例4: HandleBasicDeliver

 public void HandleBasicDeliver(IBasicConsumer consumer,
                                string consumerTag,
                                ulong deliveryTag,
                                bool redelivered,
                                string exchange,
                                string routingKey,
                                IBasicProperties basicProperties,
                                byte[] body)
 {
     UnlessShuttingDown(() =>
     {
         try
         {
             consumer.HandleBasicDeliver(consumerTag,
                                         deliveryTag,
                                         redelivered,
                                         exchange,
                                         routingKey,
                                         basicProperties,
                                         body);
         }
         catch (Exception e)
         {
             var details = new Dictionary<string, object>()
             {
                 {"consumer", consumer},
                 {"context",  "HandleBasicDeliver"}
             };
             model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
         }
     });
 }
开发者ID:hanxinimm,项目名称:rabbitmq-dotnet-client,代码行数:32,代码来源:ConcurrentConsumerDispatcher.cs


示例5: SubscriberBase

        public SubscriberBase(IModel model, string queue, IBasicConsumer consumer, SubscriberConfigurator configurator)
        {
            _model = model;

            _queue = queue;

            _consumer = consumer;
            _configurator = configurator;
        }
开发者ID:parshim,项目名称:MessageBus,代码行数:9,代码来源:SubscriberBase.cs


示例6: ConsumerOnReceived

        private void ConsumerOnReceived(IBasicConsumer sender, BasicDeliverEventArgs args)
        {
            var millisecondsTimeout = m_rnd.Next(1, 10) * 1000;
            Console.WriteLine("Message received: {0}, sleeping for {1} seconds", Encoding.UTF8.GetString(args.Body), millisecondsTimeout/1000);

            Thread.Sleep(millisecondsTimeout);

            sender.Model.BasicAck(args.DeliveryTag, false);
        }
开发者ID:simoneb,项目名称:Roger,代码行数:9,代码来源:Worker.cs


示例7: ConsumerOnReceived

        private static void ConsumerOnReceived(IBasicConsumer sender, BasicDeliverEventArgs args)
        {
            var n = int.Parse(Encoding.UTF8.GetString(args.Body));

            Console.WriteLine("Received computation request for n = {0}, correlation id {1}", n, args.BasicProperties.CorrelationId);

            var fib = Fibonacci(n);

            var properties = sender.Model.CreateBasicProperties();
            properties.CorrelationId = args.BasicProperties.CorrelationId;

            sender.Model.BasicPublish("", args.BasicProperties.ReplyTo, properties, Encoding.UTF8.GetBytes(fib.ToString()));

            sender.Model.BasicAck(args.DeliveryTag, false);
        }
开发者ID:simoneb,项目名称:Roger,代码行数:15,代码来源:FibonacciService.cs


示例8: ConsumerExecutionContext

        public ConsumerExecutionContext(
            Func<byte[], MessageProperties, MessageReceivedInfo, Task> userHandler, 
            MessageReceivedInfo info, 
            MessageProperties properties, 
            byte[] body, 
            IBasicConsumer consumer)
        {
            Preconditions.CheckNotNull(userHandler, "userHandler");
            Preconditions.CheckNotNull(info, "info");
            Preconditions.CheckNotNull(properties, "properties");
            Preconditions.CheckNotNull(body, "body");
            Preconditions.CheckNotNull(consumer, "consumer");

            UserHandler = userHandler;
            Info = info;
            Properties = properties;
            Body = body;
            Consumer = consumer;
        }
开发者ID:hippasus,项目名称:EasyNetQ,代码行数:19,代码来源:ConsumerExecutionContext.cs


示例9: HandleBasicCancelOk

 public void HandleBasicCancelOk(IBasicConsumer consumer, string consumerTag)
 {
     UnlessShuttingDown(() =>
     {
         try
         {
             consumer.HandleBasicCancelOk(consumerTag);
         }
         catch (Exception e)
         {
             var details = new Dictionary<string, object>()
             {
                 {"consumer", consumer},
                 {"context",  "HandleBasicCancelOk"}
             };
             model.OnCallbackException(CallbackExceptionEventArgs.Build(e, details));
         }
     });
 }
开发者ID:NeKoFu,项目名称:rabbitmq-dotnet-client,代码行数:19,代码来源:ConcurrentConsumerDispatcher.cs


示例10: DoAckForTest

 public void DoAckForTest(BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     DoAck(basicDeliverEventArgs, subscriptionInfo);
 }
开发者ID:vanthoainguyen,项目名称:Burrow.NET,代码行数:4,代码来源:BurrowConsumerForTest.cs


示例11: DoAck

 internal protected override void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
 {
     base.DoAck(basicDeliverEventArgs, subscriptionInfo);
     WaitHandler.Set();
 }
开发者ID:vanthoainguyen,项目名称:Burrow.NET,代码行数:5,代码来源:BurrowConsumerForTest.cs


示例12: HandleEvent

 private void HandleEvent(IBasicConsumer sender, BasicDeliverEventArgs args)
 {
     var elementBody = Encoding.Unicode.GetString(args.Body);
     var element = XElement.Parse(elementBody);
     DecodeAndRouteEvent(element);
 }
开发者ID:RussPAll,项目名称:nesper-catalyst,代码行数:6,代码来源:RabbitMqEventConsumer.cs


示例13: TestExceptionHandlingWith

        protected void TestExceptionHandlingWith(IBasicConsumer consumer, FailingOp fn)
        {
            Object o = new Object();
            bool notified = false;
            string q = Model.QueueDeclare();


            Model.CallbackException += (m, evt) => {
                notified = true;
                Monitor.PulseAll(o);
            };

            string tag = Model.BasicConsume(q, true, consumer);
            fn(Model, q, consumer, tag);
            WaitOn(o);

            Assert.IsTrue(notified);
        }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:18,代码来源:TestConsumerExceptions.cs


示例14: BasicConsume

        public string BasicConsume(string queue,
                                   bool noAck,
                                   string consumerTag,
                                   bool noLocal,
                                   bool exclusive,
                                   IDictionary<string, object> arguments,
                                   IBasicConsumer consumer)
        {
            ModelShutdown += new ModelShutdownEventHandler(consumer.HandleModelShutdown);

            BasicConsumerRpcContinuation k = new BasicConsumerRpcContinuation();
            k.m_consumer = consumer;

            Enqueue(k);
            // Non-nowait. We have an unconventional means of getting
            // the RPC response, but a response is still expected.
            _Private_BasicConsume(queue, consumerTag, noLocal, noAck, exclusive,
                                  /*nowait:*/ false, arguments);
            k.GetReply();
            string actualConsumerTag = k.m_consumerTag;

            return actualConsumerTag;
        }
开发者ID:DarthZar,项目名称:rabbitmq-dotnet-client,代码行数:23,代码来源:ModelBase.cs


示例15: BasicConsume

 public string BasicConsume(string queue, bool noAck, IDictionary filter, IBasicConsumer consumer)
 {
     throw new NotImplementedException();
 }
开发者ID:moprise,项目名称:spring-net-amqp,代码行数:4,代码来源:TestModel.cs


示例16: BasicConsume

 public string BasicConsume(string queue, bool noAck, string consumerTag, bool noLocal, bool exclusive, IDictionary<string, object> arguments,
     IBasicConsumer consumer)
 {
     throw new NotImplementedException();
 }
开发者ID:paulmccallick,项目名称:RabbitMQ.Fakes,代码行数:5,代码来源:InMemoryModel.cs


示例17:

 Task<string> ModelContext.BasicConsume(string queue, bool noAck, IBasicConsumer consumer)
 {
     return Task.Factory.StartNew(() => _model.BasicConsume(queue, noAck, consumer),
         _participant.StoppedToken, TaskCreationOptions.None, _taskScheduler);
 }
开发者ID:MassTransit,项目名称:MassTransit,代码行数:5,代码来源:RabbitMqModelContext.cs


示例18: DoAck

        internal protected override void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, IBasicConsumer subscriptionInfo)
        {
            if (IsDisposed)
            {
                return;
            }

            _subscription.Ack(basicDeliverEventArgs.ConsumerTag, basicDeliverEventArgs.DeliveryTag);
        }
开发者ID:kangkot,项目名称:Burrow.NET,代码行数:9,代码来源:PriorityBurrowConsumer.cs


示例19: SubscriptionInfo

 public SubscriptionInfo(IBasicConsumer consumer, MessageCallback callback)
 {
     Consumer = consumer;
     Callback = callback;
 }
开发者ID:redsquare,项目名称:EasyNetQ,代码行数:5,代码来源:QueueingConsumerFactory.cs


示例20: BasicConsume

 public string BasicConsume(string queue,
     bool noAck,
     string consumerTag,
     bool noLocal,
     bool exclusive,
     IDictionary<string, object> arguments,
     IBasicConsumer consumer)
 {
     var result = m_delegate.BasicConsume(queue, noAck, consumerTag, noLocal,
         exclusive, arguments, consumer);
     RecordedConsumer rc = new RecordedConsumer(this, queue).
         WithConsumerTag(result).
         WithConsumer(consumer).
         WithExclusive(exclusive).
         WithAutoAck(noAck).
         WithArguments(arguments);
     m_connection.RecordConsumer(result, rc);
     return result;
 }
开发者ID:ru-sh,项目名称:rabbitmq-dotnet-client,代码行数:19,代码来源:AutorecoveringModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IBasicProperties类代码示例发布时间:2022-05-24
下一篇:
C# IBasicAudio类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap