本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例7: ReadArgumentsFrom
public override void ReadArgumentsFrom(RabbitMQ.Client.Impl.MethodArgumentReader reader)
{
m_ticket = reader.ReadShort();
m_queue = reader.ReadShortstr();
m_noAck = reader.ReadBit();
}
示例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);
}
示例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);
}
示例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;
}
示例11: CreateInboundModel
protected internal override IModel CreateInboundModel(RabbitMQ.Client.IConnection connection,
UInt32 prefetchSize,
UInt16 prefetchCount)
{
return _model;
}