var conn = $@"host=ip:端口;virtualHost=/;username=用户名那个;password=密码;timeout=30;publisherConfirms=true"; using (var bus = RabbitHutch.CreateBus(conn).Advanced) { var message = new Message<泛型类>(泛型对象);
//声明队列后才能在RabbitMQ中看到 var queue = bus.QueueDeclare($@"队列name",(x)=>x.WithExpires(new TimeSpan(1000*60)) );//过期时间设置long类型毫秒值,先删除,不能存在同名队列,否则无法设置, bus.PublishAsync(Exchange.GetDefault(), $@"队列名", false, message) .ContinueWith(task => { if (task.IsCompleted && !task.IsFaulted) { //成功处理 } else { //失败处理 } }); }