消费者在kafka生产者/消费者重启后没有收到消息

时间:2017-09-12 12:59:34

标签: java apache-kafka spring-cloud-stream spring-kafka

我们有一个生产者和一个消费者和一个一个分区。消费者/生产者都是春季启动应用程序。消费者应用程序在我的本地机器上运行,而生产者与kafka&动物园管理员在远程机器上。

在开发期间,我重新部署了生产者应用程序并进行了一些更改。但之后我的消费者没有收到任何消息。我尝试重新启动消费者,但没有运气。可能是什么问题和/或如何解决?

消费者配置:

spring:
  cloud:
    stream:
      defaultBinder: kafka
      bindings:
        input:
          destination: sales
          content-type: application/json
      kafka:
        binder:
          brokers: ${SERVICE_REGISTRY_HOST:127.0.0.1}
          zkNodes: ${SERVICE_REGISTRY_HOST:127.0.0.1}
          defaultZkPort: 2181
          defaultBrokerPort: 9092
server:
  port: 0

制作人配置

cloud:
stream:
  defaultBinder: kafka
  bindings:
    output:
      destination: sales
      content-type: application/json
  kafka:
    binder:
      brokers: ${SERVICE_REGISTRY_HOST:127.0.0.1}
      zkNodes: ${SERVICE_REGISTRY_HOST:127.0.0.1}
      defaultZkPort: 2181
      defaultBrokerPort: 9092

EDIT2

5分钟后,消费者应用程序死亡,但有以下异常:

2017-09-12 18:14:47,254 ERROR main o.s.c.s.b.k.p.KafkaTopicProvisioner:253 - Cannot initialize Binder
org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
2017-09-12 18:14:47,255  WARN main o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext:550 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'inputBindingLifecycle'; nested exception is org.springframework.cloud.stream.binder.BinderException: Cannot initialize binder:
2017-09-12 18:14:47,256  INFO main o.s.i.m.IntegrationMBeanExporter:449 - Unregistering JMX-exposed beans on shutdown
2017-09-12 18:14:47,257  INFO main o.s.i.m.IntegrationMBeanExporter:241 - Unregistering JMX-exposed beans
2017-09-12 18:14:47,257  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: input
2017-09-12 18:14:47,257  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: nullChannel
2017-09-12 18:14:47,258  INFO main o.s.i.m.IntegrationMBeanExporter:375 - Summary on shutdown: errorChannel

2 个答案:

答案 0 :(得分:1)

看看上面关于DEBUG的建议是否显示了任何进一步的信息。看起来你从KafkaTopicProvisioner得到了一些Timeout异常。但是当你重新启动我假设的消费者时会发生这种情看起来消费者在某种程度上与经纪人沟通时遇到了一些麻烦,你需要找出那里发生的事情。

答案 1 :(得分:0)

好吧,看来spring-cloud-stream-binder-kafka已经报告了resetOffset,表明latest属性没有效果。因此,在消费者总是请求偏移为{{1}}的消息。

正如git问题所述,唯一的解决方法是通过kafka消费者CLI工具解决此问题。

相关问题