我可以使用以下代码成功发布消息: using (IAdvancedBus bus = RabbitHutch.CreateBus("host=192.168.153.128:5672;username=user;password=pass").Advanced) { IExchange exchange = bus.ExchangeDeclare("milk.api", ExchangeType.Topic); IQueue queue = bus.QueueDeclare("milkorderqueue"); IBinding binding = bus.Bind(exchange, queue, "#"); bus.Publish<MilkOrderRequest>(exchange, "#", true, new Message<MilkOrderRequest>(milkOrder)); } return new HttpResponseMessage(System.Net.HttpStatusCode.OK);当我的订阅者尝试接收消息时,EasyNetQ_Default_Error_Queue 队列会增加。这是侦听器的代码: IBus bus = RabbitHutch.CreateBus(@"host=192.168.153.128:5672;username=user;password=pass"); bus.Subscribe<MilkOrderRequest>("my_subscription_id", message => { Console.WriteLine($"Order recieved: {message.Milk}."); }, config => { config.WithQueueName("milkorderqueue"); });我也尝试了以下方法但没有成功: IAdvancedBus bus = RabbitHutch.CreateBus(@"host=192.168.153.128:5672;username=user;password=pass").Advanced; IExchange exchange = bus.ExchangeDeclare("milkshop.subscriber", ExchangeType.Topic); IQueue queue = bus.QueueDeclare("milkorderqueue"); bus.Bind(exchange, queue, "#"); bus.Consume<MilkOrderRequest>(queue, (message, info) => { Console.WriteLine($"Order recieved: {message.Body.Milk}."); });我无法在 Google 上找到有关异常的答案:messageType 不能为空
- 3 回答
- 0 关注
- 251 浏览
添加回答
举报
0/150
提交
取消