//生产者
//消息确认事件
channel.BasicAcks += Channel_BasicAcks;
。。。。。。
while (a <= 5000)//channel.WaitForConfirms()
{
//String message = Console.ReadLine();
String message = a + "......";
//消息内容
byte[] body = Encoding.UTF8.GetBytes(message);
//发送消息
channel.BasicPublish(exchange: "", routingKey: queueName, basicProperties: null, body: body);
a += 1;
Console.WriteLine("channel.NextPublishSeqNo:" + channel.NextPublishSeqNo);
}
。。。。。。
private static void Channel_BasicAcks(object sender, BasicAckEventArgs e)
{
Console.WriteLine("BasicAcks e.DeliveryTag:" + e.DeliveryTag);
Console.WriteLine("BasicAcks e.Multiple:" + e.Multiple);
}
channel.NextPublishSeqNo 每次在程序启动后都从1开始增长,和业务数据的关系建议另外处理,比如与业务数据ID一起写入本地缓存等
推荐: https://blog.csdn.net/hellozpc/article/details/81436980