【问题标题】:How to implement an example bolt with the Apache Storm javascript module?如何使用 Apache Storm javascript 模块实现示例螺栓?
【发布时间】:2016-02-16 22:59:57
【问题描述】:

有一个javascript module/library for Apache Storm,但我不记得看到任何使用它的示例。查看库,我不确定如何实现一个发出东西的示例 BasicBolt。我们有一个自定义的 Storm 拓扑构建器和管理器,所以我正在集成和运行一个 node.js 螺栓。我能够使用storm-node模块运行一个(https://www.npmjs.com/package/storm-node => https://github.com/STRML/storm-nodehttps://github.com/Lazyshot/storm-node)。但如果可能的话,我更喜欢使用准系统主 Apache Storm 库。我得到了如下。我能够记录一条消息以进行风暴,但无法将数据发送到拓扑中的下一个螺栓以供使用。我在想我没有正确调用 emit() 函数。使用storm-node,发出我想要的东西要容易得多。任何想法我做错了什么或错过了什么?

var ExampleBolt = require("./storm.js").BasicBolt;

ExampleBolt.prototype.process = function(tuple, done) {
    this.log("loggedamessage");
    var data = JSON.stringify(tuple.values);
    //originally tried something like this...
    //this.emit([data]);
    this.emit({'tuple':data,'anchorTupleId':tuple.values},function taskIdHandler(taskId){ return; });
    done();
};

var bolt = new ExampleBolt();
bolt.run();

不幸的是,我使用的storm基础设施没有报告任何关于节点螺栓的有用的运行时错误,以便我找出问题。

【问题讨论】:

标签: javascript node.js apache-storm


【解决方案1】:

https://github.com/apache/storm/blob/master/examples/storm-starter/multilang/resources/splitsentence.js

是一个测试拆分语句螺栓,用作我们测试的一部分。它应该为您提供一个很好的起点。

【讨论】:

  • 我已经尝试过这个例子......但我不知道如何将输入提供给创建的风暴螺栓。以及如何将 node.js 中的拓扑提交给storm?
猜你喜欢
  • 2014-07-29
  • 1970-01-01
  • 2018-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多