Disruptor丢弃消息问题

时间:2017-03-16 16:52:42

标签: disruptor-pattern

我们已经将LMAX Disruptor用于生产近一年了。直到上周我们看到Disruptor发出的消息时,一切都很好。我们的Disruptor结构非常简单:

Kafka - > RingBuffer - > Eventhandler1 - > Eventhandler2 - > Eventhandler3

每个Eventhandler都有一个try-catch块来捕获所有异常。最慢的是Eventhandler2,每条消息需要大约3毫秒。

我们向Kafaka发送了53条消息,所有消息都由Eventhandler1处理。但不知怎的,Eventhandler2和Eventhandler3只收到了23条消息,我们在日志中没有看到任何异常。

我们试图在我们的开发环境中重现这一点,但我们没有看到这个问题。

所以我的问题是:

  1. Disruptor是否可以删除邮件?
  2. 如果是,在什么条件下它可能会丢弃消息?

1 个答案:

答案 0 :(得分:1)

我在生产和使用负载测试测试环境时遇到了同样的问题。 如果您有2个或更多并发生成器(环形缓冲区发布者)但是使用ProducerType.SINGLE初始化Disruptor,它可能会丢失或表现不可预测。请检查一下。

ProducerType.MULTI用法示例:

def update
  @person = Person.find(params[:id])
  respond_to do |format|
    if @person.update_attributes(person_params)
      format.html { redirect_to persons_path }
    else
      # @person.restore_attributes works for restoring the @person 
      # input values. I would like to do something like 
      # @person.pet.restore_attributes
      format.html { render :edit }
    end
  end
end