Apache Storm在Kafka-topic中按顺序写入数字

时间:2017-02-09 18:04:07

标签: apache-kafka apache-storm stream-processing

我想用kafka和storm进行一些性能测试。在我的WordCount测试中,顺序编号到达“输出” - 主题:

uLK 1
1352 
GaE 1
1353
IGF 1
1354 
DtJ 2
1355 
MVy 1
...

应该是这样的:

uLK 1
GaE 1
IGF 1
DtJ 2 
MVy 1
...

我的风暴拓扑结构如下:

builder.setSpout("kafkaSpoutPerfTest", kafkaSpout, 1);

builder.setBolt("split", new SplitSentence(), paralellismHint).shuffleGrouping("kafkaSpoutPerfTest");
builder.setBolt("count", new WordCount(), paralellismHint).fieldsGrouping("split", new Fields("message"));

Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("acks", "0");
props.put("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
props.put("value.serializer","org.apache.kafka.common.serialization.StringSerializer");

KafkaBolt kafkaBolt = new KafkaBolt()
                .withProducerProperties(props)
                .withTopicSelector(new DefaultTopicSelector("output"));

builder.setBolt("kafkaBoltOutput", kafkaBolt, 1).shuffleGrouping("count");

我做错了什么?有一些线索吗?谢谢!

0 个答案:

没有答案