繁体   English   中英

Twitter Storm,为什么螺栓无法接收到喷头发送的信息

[英]Twitter Storm, why is the bolt not recieving what the spout sends

我在一个项目中使用Twitter Storm,但遇到了一个奇怪的问题。 我有下面的nextTuple代码的喷口:

public void nextTuple()
{
    HashMap cluster = this.databaseManager.getCluster();
    System.out.println("emitted: " + cluster);
    this.collector.emit(new Values(cluster));
}

然后执行以下操作,将螺栓连接到此喷嘴:

public void execute(Tuple tuple)
{
    HashMap<String, List<String>> unigrams = (HashMap)tuple.getValueByField("unigrams");
    System.out.println("received: " + unigrams);
}

发出的内容应与正确接收的内容相同? 因此,首先输出显示如下:

emitted: {218460=[04ef110987074dc6b3e3174b9f57d980], 1702472=[04ef110987074dc6b3e3174b9f57d980]}
received: {218460=[04ef110987074dc6b3e3174b9f57d980], 1702472=[04ef110987074dc6b3e3174b9f57d980]}

(数据的含义是无关紧要的,关键是它的发送和接收)。 但是,当发射改变时,接收到的是相同的:

emitted: {13788873=[aa2ec732b5b64b25be81abe79d2176bb], 2293158=[aa2ec732b5b64b25be81abe79d2176bb], 218460=[04ef110987074dc6b3e3174b9f57d980], 1702472=[04ef110987074dc6b3e3174b9f57d980]}
received: {218460=[04ef110987074dc6b3e3174b9f57d980], 1702472=[04ef110987074dc6b3e3174b9f57d980]}

我在想为什么第二种情况不起作用。 此外,输出从nextTuple打印的内容比从执行输出的内容要多得多。

任何想法为什么会这样?

我发现的唯一解决方案是在发送之前将HashMap转换为字符串,然后在螺栓中转换回HashMap。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM