Clojure Storm Flux

时间:2016-05-23 11:57:46

标签: clojure apache-storm apache-storm-flux

我最近开始使用Apache Storm。我使用Storm Clojure Storm DSLLeiningen

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

我的问题是:当我在风暴中使用clojure进行编码时,如何使用通量?

1 个答案:

答案 0 :(得分: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 :all添加到your project.clj

并且在你的通量topology.yaml中有类似的东西:

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

这就是全部:)