我找到了解决方案:
(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 。
:aot :all
your project.clj
在你的流量 topology.yaml 就像是:
topology.yaml
... bolts: - id: "myBolt" className: "your.namespace.boltname" parallelism: 1 ...
就这样 :)