David
David

Reputation: 3441

How to implement an example bolt with the Apache Storm javascript module?

There's a javascript module/library for Apache Storm, but I don't recall seeing any examples using it. Looking at the library, I'm not sure how to implement an example BasicBolt that emits stuff. We have a custom Storm topology builder and manager, so I'm integrating and running a node.js bolt with that. I was able to get one running with the storm-node modules (https://www.npmjs.com/package/storm-node => https://github.com/STRML/storm-node, https://github.com/Lazyshot/storm-node). But I'd prefer to use the barebones main Apache Storm library if possible. I got as far as follows below. Am able to log a message to storm, but not able to emit data to the next bolt in the topology to consume. I'm thinking I am not calling the emit() function correctly. With storm-node, it was much easier to emit what I wanted. Any ideas what I'm doing wrong or missing?

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();

And unfortunately, the storm infrastructure I'm using does not report any useful runtime errors regarding the node bolt for me to figure out the problem.

Upvotes: 1

Views: 2124

Answers (1)

Bobby Evans
Bobby Evans

Reputation: 136

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

is a test split sentence bolt that is used as part of our tests. It should give you a good place to start.

Upvotes: 3

Related Questions