我编写了一个 spring 云流应用程序来接收来自 Kafka 主题的消息。我正在尝试设置消费者组,这样当我扩展我的应用程序时,只有一个应用程序实例接收来自 Kafka 主题的消息。
以下是我的 application.yml
spring:
cloud:
stream:
bindings:
orderTopic:
group: orderGroup
destination: orderTopic
kafka:
binder:
brokers: 192.168.61.21
defaultBrokerPort: 9092
zkNodes: 192.168.61.21
defaultZkPort: 2181
我已将应用程序部署到 Cloud Foundry (pcfdev) 并将应用程序的实例计数设置为 2。当我向 orderTopic 主题发送订单时,我希望只有 2 个应用程序实例中的一个收到订单, 但是,两个应用程序实例都收到相同的顺序,如下所示
2016-05-10T16:33:46.42-0600 [APP/0] OUT Order Number 23 received.
2016-05-10T16:33:47.42-0600 [APP/1] OUT Order Number 24 received.
2016-05-10T16:33:47.42-0600 [APP/0] OUT Order Number 24 received.
2016-05-10T16:33:48.42-0600 [APP/1] OUT Order Number 25 received.
2016-05-10T16:33:48.42-0600 [APP/0] OUT Order Number 25 received.
2016-05-10T16:33:49.43-0600 [APP/1] OUT Order Number 26 received.
2016-05-10T16:33:49.43-0600 [APP/0] OUT Order Number 26 received.
你能帮忙吗