【发布时间】:2015-05-20 18:02:16
【问题描述】:
我正在尝试将 Apache Storm 与 Kafka 集成。连接似乎建立得很好,但没有收到任何消息。但是消息似乎也已发送到 Kafka 服务器,而 Kafka 服务器中相应主题的索引文件显示存在一些数据。有没有办法在 Storm end 上进行更多调试..?我在 Storm 中使用客户解码器来接收消息。 Storm 的实现是:
TopologyBuilder builder = new TopologyBuilder();
Broker brokerForPartition0 = new Broker("xxxxx");
GlobalPartitionInformation partitionInfo = new GlobalPartitionInformation();
partitionInfo.addPartition(0, brokerForPartition0);
StaticHosts hosts = new StaticHosts(partitionInfo);
SpoutConfig spoutConfig = new SpoutConfig(hosts, TOPIC, "/"+TOPIC, clientId);
spoutConfig.scheme = new MyLogScheme();
builder.setSpout("spout", new KafkaSpout(spoutConfig));
builder.setBolt("printer", new PrinterBolt());
Config conf = new Config();
conf.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("test", conf, builder.createTopology());
【问题讨论】:
-
你可以使用控制台-消费者脚本来消费来自 kafka 的消息吗?运行拓扑时会发生什么?你看到什么错误了吗?
-
我在控制台消费者脚本中接收消息。但是对于这个测试,我使用了另一个主题。由于我的应用程序中使用的主题消息具有自定义解码器。
-
拓扑启动时,连接到kafka没有任何错误,并定期尝试从队列中获取消息,但没有收到任何消息。
-
您需要确保主题没有损坏并且包含有效数据。另一方面,使用您的 kafka sppout 来使用您使用控制台消费者脚本测试过的主题中的消息跨度>
标签: java apache-kafka apache-storm