Search code examples
clojureapache-stormapache-storm-flux

Clojure Storm Flux


I started to work with Apache Storm recently. I use Storm with Clojure Storm DSL and Leiningen.

There is a very cool tool for storm topology management: Storm Flux.

My question is: How can I use flux when I am coding in storm with clojure?


Solution

  • I found a solution:

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

    don't forget to add :aot :all to your project.clj.

    And in your flux topology.yaml something like:

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

    That's all :)