我从不同的Kafka主题中读取了多个OpaqueTridentKafkaSpout。我希望所有这些流中的数据都通过相同的函数集。实现这一目标的最佳方法是什么? 我是否需要创建单独的流并再次将每个元组传递给同一组函数。如下所示?
BrokerHosts zk = new ZkHosts(getZooKeeperHosts());
TridentKafkaConfig spoutConf = new TridentKafkaConfig(zk, "Test");
spoutConf.scheme = new SchemeAsMultiScheme(new StringScheme());
TridentKafkaConfig spoutConf1 = new TridentKafkaConfig(zk, "Test1");
spoutConf1.scheme = new SchemeAsMultiScheme(new StringScheme());
OpaqueTridentKafkaSpout kafkaSpout1 = new OpaqueTridentKafkaSpout(spoutConf1);
topology.newStream("event", kafkaSpout).each(new Fields("document"), new ExtractDocumentInfo(), new Fields("id", "index", "type"));
topology.newStream("event1", kafkaSpout1).each(new Fields("document"), new ExtractDocumentInfo(), new Fields("id", "index", "type"));
答案 0 :(得分:0)
您可以将流合并在一起,但任何失败都会导致两个spouts重播批处理。