简体   繁体   English

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

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

I am using Twitter Storm in a project and I have a strange problem. 我在一个项目中使用Twitter Storm,但遇到了一个奇怪的问题。 I have a spout with the following nextTuple code: 我有下面的nextTuple代码的喷口:

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

And a bolt which is connected to this spout with the following execute: 然后执行以下操作,将螺栓连接到此喷嘴:

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

What is emitted should be the same as what is recieved right? 发出的内容应与正确接收的内容相同? So at first the output shows this: 因此,首先输出显示如下:

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

(It is irreverent what the data means, the point is that it is emitted and received). (数据的含义是无关紧要的,关键是它的发送和接收)。 But then, when the emitted is changed, the received is the same: 但是,当发射改变时,接收到的是相同的:

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

I am banging my has to why it doesn't work in the second case. 我在想为什么第二种情况不起作用。 Furthermore, the output is printing a lot more from the nextTuple than it is from the execute. 此外,输出从nextTuple打印的内容比从执行输出的内容要多得多。

Any ideas why this is? 任何想法为什么会这样?

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

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

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