2

我最近开始使用Apache Storm 。我将 Storm 与Clojure Storm DSLLeiningen一起使用。

风暴拓扑管理有一个非常酷的工具:Storm Flux

我的问题是:当我使用 clojure 在 Storm 中编码时,如何使用 Flux?

4

1 回答 1

1

我找到了一个解决方案:

(ns your.namespace.boltname
  (:use
    [org.apache.storm clojure config])
  (:gen-class :implements [org.apache.storm.topology.IRichBolt]))

(defbolt my-bolt
         ["data"]
         [tuple collector]
         (emit-bolt! collector [(f (.getString tuple 0))] :anchor tuple)
         (ack! collector tuple))

(defn -execute [this tuple]
 (.execute my-bolt tuple))

(defn -prepare [this conf context collector]
 (.prepare my-bolt conf context collector))

(defn -cleanup [this]
 (.cleanup my-bolt))

(defn -declareOutputFields [this output]
 (.declareOutputFields my-bolt output))

(defn -getComponentConfiguration [this]
 (.getComponentConfiguration my-bolt))

不要忘记添加:aot :allyour project.clj.

在您的流量中topology.yaml,例如:

...
bolts:
  - id: "myBolt"
    className: "your.namespace.boltname"
    parallelism: 1
...

就这样 :)

于 2016-06-01T09:38:31.853 回答