0

我尝试使用普通消费者示例来检索消息。但现在我的消费者是风暴,所以我需要在风暴中存储批量 kafka 消息需要一些示例。

4

1 回答 1

0

我正在使用storm-kafka喷口。您可以在他们的页面上找到几个示例。我在我的应用程序中需要这个KafkaSpout类,但它们似乎也支持批处理:

Fields fields = new Fields("key", "message");
FixedBatchSpout spout = new FixedBatchSpout(fields, 4,
            new Values("storm", "1"),
            new Values("trident", "1"),
            new Values("needs", "1"),
            new Values("javadoc", "1")
);
spout.setCycle(true);
builder.setSpout("spout", spout, 5);

如果您需要更具体的示例,请缩小问题范围。

于 2015-04-08T08:14:04.190 回答