Clojure风暴流量

Clojure风暴流量,clojure,apache-storm,apache-storm-flux,Clojure,Apache Storm,Apache Storm Flux,我最近开始和你一起工作。我用Storm和and 有一个非常酷的风暴拓扑管理工具: 我的问题是:当我使用clojure在storm中编码时,如何使用flux?我找到了一个解决方案: (ns your.namespace.boltname (:use [org.apache.storm clojure config]) (:gen-class :implements [org.apache.storm.topology.IRichBolt])) (defbolt my-bolt

我最近开始和你一起工作。我用Storm和and

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

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

我找到了一个解决方案:

(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
添加到
项目中。clj

在flux
拓扑中.yaml
类似于:

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

仅此而已:)

我不确定,但我想您需要将clojure代码编译成类文件(对于每个喷口,bolt),以便在flux中使用这些类文件。谢谢@MatthiasJ.Sax,我尝试了这个解决方案,但我错过了一些东西。在我的ns中,我使用:gen类,例如我的deffout宏。但是编译后的文件没有使用IRichSpout对象生成类:(您了解吗?或者您有一个小例子?您需要使用
reify
继承接口。请参阅@MatthiasJ.Sax您认为这个解决方案如何?我不能使用reify,因为在运行之前需要一个类time@MatthiasJ.Sax你觉得这个解决方案怎么样?我不能使用具体化,因为我之前需要上课运行时间