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


C# RabbitMQ类代码示例

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


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

示例1: Implement

 protected override void Implement(RabbitMQ.Client.IModel channel, RabbitMQ.Client.Events.BasicDeliverEventArgs ea)
 {
     var body = ea.Body;
     var message = Encoding.UTF8.GetString(body);
     Console.WriteLine(" worker1 Received {0}", message);
     System.Threading.Thread.Sleep(10000);
     channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
 }
开发者ID:ramanmittal,项目名称:rabbitmq,代码行数:8,代码来源:Worker1.cs

示例2: Publish

        internal static void Publish(string exchangeName, string routingKey, With.Message.ISerializer messageSerializer, RabbitMQ.Client.IModel model, With.Message.IMessage message)
        {
            string content = messageSerializer.Serialize(message);
            byte[] body = Encoding.Encode(content);
            IBasicProperties properties = model.CreateBasicProperties();

            model.BasicPublish(exchangeName, routingKey, properties, body);
        }
开发者ID:Zananok,项目名称:Harmonize,代码行数:8,代码来源:Producer.cs

示例3: HandleCall

 public override byte[] HandleCall(bool isRedelivered, RabbitMQ.Client.IBasicProperties requestProperties, byte[] body, out RabbitMQ.Client.IBasicProperties replyProperties)
 {
     string productName = ASCIIEncoding.ASCII.GetString(body);
     Console.WriteLine("Received order for producted named '{0}'", productName);
     string orderId = Guid.NewGuid().ToString();
     replyProperties = requestProperties;
     byte[] respBody = ASCIIEncoding.ASCII.GetBytes(orderId);
     return respBody;
 }
开发者ID:jixer,项目名称:sb-demos,代码行数:9,代码来源:MySimpleRpcServer.cs

示例4: BasicGetResult

 // Summary:
 //     Sets the new instance's properties from the arguments passed in.
 public BasicGetResult(RabbitMQ.Client.BasicGetResult result)
 {
     BasicProperties = result.BasicProperties;
     Body = result.Body;
     DeliveryTag = result.DeliveryTag;
     Exchange = result.Exchange;
     MessageCount = result.MessageCount;
     Redelivered = result.Redelivered;
     RoutingKey = result.RoutingKey;
 }
开发者ID:jhonner72,项目名称:plat,代码行数:12,代码来源:BasicGetResult.cs

示例5: Consumer_ConnectionLost

 private void Consumer_ConnectionLost(RabbitMQ.Client.IConnection connection,
     RabbitMQ.Client.ShutdownEventArgs reason)
 {
     Consumer.ConnectionLost -= Consumer_ConnectionLost;
     Log.Warning("Connection lost to RabbitMQ Server due to {0}", reason.Cause);
     try
     {
         Consumer.StartConsuming();
     }
     catch (Exception ex)
     {
         Log.Warning(ex, "Shutting down old connection to allow new connection to replace it");
     }
     InitializeQueueConnection();
     StartConsuming();
 }
开发者ID:jhonner72,项目名称:plat,代码行数:16,代码来源:ProcessingService.cs

示例6: WriteArgumentsTo

 public override void WriteArgumentsTo(RabbitMQ.Client.Impl.MethodArgumentWriter writer)
 {
     writer.WriteShort(m_replyCode);
       writer.WriteShortstr(m_replyText);
       writer.WriteShortstr(m_exchange);
       writer.WriteShortstr(m_routingKey);
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:7,代码来源:autogenerated-api-0-9.cs

示例7: ReadArgumentsFrom

 public override void ReadArgumentsFrom(RabbitMQ.Client.Impl.MethodArgumentReader reader)
 {
     m_ticket = reader.ReadShort();
       m_queue = reader.ReadShortstr();
       m_noAck = reader.ReadBit();
 }
开发者ID:parshim,项目名称:rabbitmq-dotnet-client,代码行数:6,代码来源:autogenerated-api-0-9.cs

示例8: DSDPSNode_ConnectionShutdown

 private void DSDPSNode_ConnectionShutdown(object sender, RabbitMQ.Client.ShutdownEventArgs e)
 {
     Console.WriteLine("[Error] Disconnected from rabbitMQ server.");
     //if(updateManager.updateBlockingMRE.WaitOne())
         Environment.Exit(8);
 }
开发者ID:daishin-securities,项目名称:DSDistributedProcessingSystem,代码行数:6,代码来源:DSDPSNode.cs

示例9: CreateConnection

        private IConnection CreateConnection(RabbitMQ.Client.IConnection connection,
                                             IModel outboundModel)
        {
            var builder = new ConsumedMessageBuilder(_configuration.SerializationConfiguration,
                                                     _configuration.MessageTypeResolver);
            var outboundChannel = _configuration.OutboundChannelBuilder(outboundModel,
                                                                        _configuration);
            var consumers = _promises.Select(_ =>
                                                {
                                                    var model = CreateInboundModel(connection,
                                                                                   _configuration.PrefetchSize,
                                                                                   _configuration.PrefetchCount);
                                                    var consumer = _(builder).BuildConsumer(new InboundChannel(model),
                                                                                            outboundChannel);
                                                    return new { Model = model, Consumer = consumer };
                                                })
                                     .ToList();

            foreach (var consumer in consumers)
                consumer.Consumer.Declare(consumer.Model);

            return new Connection(connection,
                                  consumers.Select(_ => _.Consumer),
                                  outboundChannel,
                                  _configuration);
        }
开发者ID:naighes,项目名称:Carrot,代码行数:26,代码来源:Broker.cs

示例10: CreateInboundModel

 protected internal virtual IModel CreateInboundModel(RabbitMQ.Client.IConnection connection,
                                                      UInt32 prefetchSize,
                                                      UInt16 prefetchCount)
 {
     var model = connection.CreateModel();
     model.BasicQos(prefetchSize, prefetchCount, false);
     return model;
 }
开发者ID:naighes,项目名称:Carrot,代码行数:8,代码来源:Broker.cs

示例11: CreateInboundModel

 protected internal override IModel CreateInboundModel(RabbitMQ.Client.IConnection connection,
                                                       UInt32 prefetchSize,
                                                       UInt16 prefetchCount)
 {
     return _model;
 }
开发者ID:lsfera,项目名称:Carrot,代码行数:6,代码来源:Connecting.cs


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