首页 > 解决方案 > 为什么发布时 RabbitMQ 超时(使用交换联合)?

问题描述

关于背景信息,我们是一家拥有 200 多家商店的零售商公司。我们使用 rabbitmq 联合 200 多个 RabbitMQ 服务器(每个商店一个服务器)。每个 RabbitMQ 服务器有 4 个交换器。所以总共有大约800个交易所。

有一个发布消息的中央服务器。这用作其他 200 台服务器的上游服务器。当产品发生变化时,会向中央服务器发送一条消息,该消息将转发到其他rabbitmq服务器并在每个商店本地处理。我们的应用程序在 Windows 服务器上的 .NET 框架上运行(使用 Masstransit 处理 RabbitMQ)。

有时,我们在向 rabbitMQ 发布事件时会遇到超时错误。这是一个例子:

Properties  
message_id: f68a0000-15f3-0670-085b-08d66b92a0b1
delivery_mode:  2
headers:    
x-correlation-id:   18799970-fea8-431e-8608-d02496194a0a
Content-Type:   application/vnd.masstransit+json
publishId:  1
MT-Reason:  fault
MT-Fault-Message:   Publishing message of type MyCompany.Event.Message timed out after 5000 milliseconds.
MT-Fault-Timestamp: 2018-12-27T00:32:33.6076503Z
MT-Fault-StackTrace:    at MyCompany.ProductCommand.Listener.UpsertProductCommandListener.<PublishMessage>d__10`1.MoveNext() 
at MyCompany.ProductCommand.Listener.UpsertProductCommandListener.<PublishUpdatedEvents>d__8.MoveNext() 
at MyCompany.ProductCommand.Listener.UpsertProductCommandListener.<Consume>d__7.MoveNext() 
at MassTransit.AutofacIntegration.AutofacConsumerFactory`1.<Send>d__3`1.MoveNext() 
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.<GreenPipes-IFilter<MassTransit-ConsumeContext<TMessage>>-Send>d__4.MoveNext() 
at MassTransit.Pipeline.Filters.ConsumerMessageFilter`2.<GreenPipes-IFilter<MassTransit-ConsumeContext<TMessage>>-Send>d__4.MoveNext() 
at GreenPipes.Filters.TeeFilter`1.<Send>d__5.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at GreenPipes.Filters.OutputPipeFilter`2.<GreenPipes-IFilter<TInput>-Send>d__6.MoveNext() 
at MassTransit.Pipeline.Filters.DeserializeFilter.<Send>d__4.MoveNext() 
at GreenPipes.Filters.RescueFilter`2.<GreenPipes-IFilter<TContext>-Send>d__5.MoveNext()
MT-Host-MachineName:    WIN-123456
MT-Host-ProcessName:    MyCompany.ProductCommandListener.WindowsService
MT-Host-ProcessId:  848
MT-Host-Assembly:   MyCompany.ProductCommandListener.WindowsService
MT-Host-AssemblyVersion:    1.0.0.0
MT-Host-MassTransitVersion: 3.5.4.992
MT-Host-FrameworkVersion:   4.0.30319.42000
MT-Host-OperatingSystemVersion: Microsoft Windows NT 6.2.9200.0
content_type:   application/vnd.masstransit+json

每条消息大约 5000 字节。我们想了解消息是如何超时的。我们在 rabbitMQ 网站上发现了这个关于 ack 行为的信息:

For routable messages, the basic.ack is sent when a message has been accepted by all the queues. For persistent messages routed to durable queues, this means persisting to disk. For mirrored queues, this means that all mirrors have accepted the message. https://www.rabbitmq.com/confirms.html#when-publishes-are-confirmed

但是,我们找不到任何有关在联合中发布确认行为的信息。所以我们的问题是

  1. 在交换联合中,当所有下游服务器都收到消息或上游服务器将消息持久化到磁盘时,代理会发送发布确认?
  2. 如何解决超时错误?

任何帮助,将不胜感激。

标签: rabbitmqrabbitmq-federation

解决方案


推荐阅读