clojure风暴通量

2nbm6dog  于 2021-06-21  发布在  Storm
关注(0)|答案(1)|浏览(494)

我最近开始和apachestorm合作。我将storm与clojure storm dsl和leiningen结合使用。
风暴拓扑管理有一个非常酷的工具:风暴通量。
我的问题是:当我用clojure在storm中编写代码时,如何使用flux?

pbgvytdp

pbgvytdp1#

我找到了解决办法:

(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
...

仅此而已:)

相关问题