SlideShare a Scribd company logo
WRAPPING JAVA IN 
AWESOMENESS 
CONDENSATOR 
REACTIVE COMMUNICATION 
OVER TCP
TERO KADENIUS (@PISKETTI) 
Clojure enthusiast, recovering Java programmer 
JUHA HEIMONEN (@EVILBUBU) 
Clojure N00b 
We are part of Flowa (@FlowaWolf)
FIRST THINGS FIRST 
Infrastructure of what you currently see
WAIT... 
Let's see if we can attach another crucial part 
Executed function: 
(defn attach-command-listener! [] 
(condensator/on c "command" 
(fn [{data :data}] 
(case data 
"right" (right-sound) 
"left" (left-sound) 
nil)) 
{:address address :port port}))
NOW IT IS LIKE THIS. 
New Infrastructure view
ONE MORE THING
WE CAN SEND MESSAGES OTHER 
WAY AROUND
WHAT? 
Condensator = 
Spring Reactor (Java) 
Meltdown (Awesome Clojure by Clojurewerkz)
CONDENSATOR CONTAINS 
TCP messaging capability on top of Spring Reactor and 
Meltdown (by Clojurewerkz). 
So in overall, you get a system that implements Reactor 
pattern with TCP transport.
REACTOR PATTERN 
Event handling pattern 
Synchronous dispatching of events (Executes when it's 
possible to do so without blocking) 
Coarserly concurrent, doesn't use multiple threads
API 
(defn create 
"Creates condensator based on meltdown or tcp capable condensator" 
([address port]) 
([])) 
(defn notify 
"Notifies condensator with payload based on selector" 
([condensator selector payload]) 
([selector payload {:keys [address port]}])) 
(defn on 
"Attaches listener to condensator" 
([condensator selector cb]) 
([condensator selector cb {:keys [address port]}])) 
(defn receive-event [condensator selector cb]) 
(defn send-event [condensator selector data cb])
WHY BUILD ON TOP OF A JAVA 
LIBRARY?
NO NEED TO REINVENT THE 
WHEEL 
THERE ARE A LOT OF STUFF WRITTEN IN JAVA 
ALREADY 
MATURITY - QUITE A BIT OF JAVA STUFF IS BATTLE 
TESTED FOR YOU
USING A JAVA LIBRARY DIRECTLY 
CAN BE A BIT...
(let [calculator (FooCalculator.) 
inputBean (doto (InputBean.) 
(.setFoo (Integer. 1)) 
(.setBar (Integer. 2)) 
(.setBaz (Integer. 3)))] 
(.setInput calculator inputBean) 
(.performCalculation calculator) 
(let [resultBean (.getCalculationResultBean calculator) 
subresultA (.getSubresultA resultBean) 
subresultB (.getSubresultB resultBean)] 
;; Do something with the result 
))
(let [{:keys [subresult-a subresult-b]} (calc {:foo 1 :bar 2 :baz 3})] 
;; Do something with the result 
)
RANDOM LEARNINGS... 
Shape of an API matters 
(Clojure ones tend to be simple. Big surprise!) 
"Clojure is not for geniuses" 
-Adam Bard 
"idiot-friendly design" 
-Adam Bard
RANDOM LEARNINGS CONTINUED 
Wrapping Java to Clojure is pretty much controlling mutability 
and restricting state 
(def c (condensator/create)) 
... 
(condensator/on c "command" (fn [{data :data}] ...) 
Restrict mutable java to one instance, pass it with immutable 
data to clojure API
RANDOM LEARNINGS CONTINUED 
#2 
Testing asynchronous stuff is surprisingly simple with 
promises 
(it "remote notifies and locally executes listener" 
(let [datapromise (promise)] 
(condensator/on server "remote" 
(fn [data] 
(info datapromise) 
(deliver datapromise (:data data)))) 
(tcp/send-tcp-msg 
:port 3030, 
:operation :notify, 
:selector "remote", 
:data "from-remote") 
(let [result (deref datapromise 3000 nil)] 
(should= "from-remote" result)))) 
A daily dose of Clojure increases programmer happiness by 
63%
THANK YOU 
https://github.com/flowa/condensator

More Related Content

What's hot (20)

PDF
Learn You a ReactiveCocoa for Great Good
Jason Larsen
 
PPTX
AMC Minor Technical Issues
Apache Traffic Server
 
PPTX
Avoiding Callback Hell with Async.js
cacois
 
PDF
Kotlin workshop
Jedsada Tiwongvokul
 
PDF
Cocoa heads 09112017
Vincent Pradeilles
 
PDF
Advanced functional programing in Swift
Vincent Pradeilles
 
PDF
Runtime Bytecode Transformation for Smalltalk
Marcus Denker
 
PDF
Swift Sequences & Collections
CocoaHeads France
 
PDF
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB
 
PDF
Monads in Swift
Vincent Pradeilles
 
PDF
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
PPTX
Functional Reactive Endpoints using Spring 5
Rory Preddy
 
PDF
Kotlin wonderland
Jedsada Tiwongvokul
 
PPTX
Reactive Java (33rd Degree)
Tomasz Kowalczewski
 
PDF
Intro to ReactiveCocoa
kleneau
 
PDF
Javascript Promises/Q Library
async_io
 
PPTX
Twig + drupal 8
Logan Farr
 
PDF
JavaOne 2013: Java 8 - The Good Parts
Konrad Malawski
 
PDF
Building Scalable Stateless Applications with RxJava
Rick Warren
 
PDF
Chapter24 operator-overloading
Deepak Singh
 
Learn You a ReactiveCocoa for Great Good
Jason Larsen
 
AMC Minor Technical Issues
Apache Traffic Server
 
Avoiding Callback Hell with Async.js
cacois
 
Kotlin workshop
Jedsada Tiwongvokul
 
Cocoa heads 09112017
Vincent Pradeilles
 
Advanced functional programing in Swift
Vincent Pradeilles
 
Runtime Bytecode Transformation for Smalltalk
Marcus Denker
 
Swift Sequences & Collections
CocoaHeads France
 
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB
 
Monads in Swift
Vincent Pradeilles
 
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
Functional Reactive Endpoints using Spring 5
Rory Preddy
 
Kotlin wonderland
Jedsada Tiwongvokul
 
Reactive Java (33rd Degree)
Tomasz Kowalczewski
 
Intro to ReactiveCocoa
kleneau
 
Javascript Promises/Q Library
async_io
 
Twig + drupal 8
Logan Farr
 
JavaOne 2013: Java 8 - The Good Parts
Konrad Malawski
 
Building Scalable Stateless Applications with RxJava
Rick Warren
 
Chapter24 operator-overloading
Deepak Singh
 

Viewers also liked (20)

PPTX
88 gibraltar investment presentation
88gibraltar
 
PPTX
Shri Krsna
virendra1984
 
PPTX
智慧城市
Yu-Ting Lai
 
PDF
Cross Border VC Syndication. Tibet Presentation
Daniel S. Hain
 
PPTX
Accounting project working
usman nazir
 
PPTX
Telšių rajono savivaldybės patirtis įsisavinant ES paramą
Jurgita Telšiai
 
PPTX
第3回なんでも勉強会 にゃんたこす rev01
Toshiaki Yamanishi
 
PPTX
Tong quan ve elearning_nhom14
Nguyễn Lê Thảo Trâm
 
PPTX
Coaching teams in Creative Problem Solving v.2
Flowa Oy
 
DOCX
Embedded
ChandruSimbu
 
PDF
New design knowlege - Manzini
Francisco Gómez Castro
 
PDF
88 Gibraltar Product Presentation
88gibraltar
 
PPT
リアル脱出ゲームのゲームデザイン論
Toshiaki Yamanishi
 
DOCX
ieee 2014-15 projects titles for java and dotnet
ChandruSimbu
 
PDF
Conference mec business_seminar_dilek_tokay_workshop
Bünyamin YILDIZ
 
PDF
Tresemme Weather Looks
Mariela Diaz
 
DOCX
Aspirador de pó com ciclone
Adalto B Ferreira
 
PPTX
Chicken buiscuit
usman nazir
 
88 gibraltar investment presentation
88gibraltar
 
Shri Krsna
virendra1984
 
智慧城市
Yu-Ting Lai
 
Cross Border VC Syndication. Tibet Presentation
Daniel S. Hain
 
Accounting project working
usman nazir
 
Telšių rajono savivaldybės patirtis įsisavinant ES paramą
Jurgita Telšiai
 
第3回なんでも勉強会 にゃんたこす rev01
Toshiaki Yamanishi
 
Tong quan ve elearning_nhom14
Nguyễn Lê Thảo Trâm
 
Coaching teams in Creative Problem Solving v.2
Flowa Oy
 
Embedded
ChandruSimbu
 
New design knowlege - Manzini
Francisco Gómez Castro
 
88 Gibraltar Product Presentation
88gibraltar
 
リアル脱出ゲームのゲームデザイン論
Toshiaki Yamanishi
 
ieee 2014-15 projects titles for java and dotnet
ChandruSimbu
 
Conference mec business_seminar_dilek_tokay_workshop
Bünyamin YILDIZ
 
Tresemme Weather Looks
Mariela Diaz
 
Aspirador de pó com ciclone
Adalto B Ferreira
 
Chicken buiscuit
usman nazir
 
Ad

Similar to Wrapping java in awesomeness aka condensator (20)

PDF
Introduction to Clojure
Renzo Borgatti
 
PDF
5 little clojure functions
Diego Pacheco
 
ODP
Getting started with Clojure
John Stevenson
 
PDF
Clojure for Java developers
John Stevenson
 
PDF
The Ideas of Clojure - Things I learn from Clojure
Hsuan Fu Lien
 
PDF
Clojure Programming Cookbook Makoto Hashimoto Nicolas Modrzyk
mbouemugnia
 
PDF
HelsinkiJS - Clojurescript for Javascript Developers
Juho Teperi
 
ODP
Clojure made really really simple
John Stevenson
 
PPTX
Clojure Fundamentals Course For Beginners
Paddy Lock
 
PDF
Functional (web) development with Clojure
Henrik Eneroth
 
PDF
Clojure+ClojureScript Webapps
Falko Riemenschneider
 
PDF
Clojure in real life 17.10.2014
Metosin Oy
 
PDF
'Getting' Clojure - '(parentheses are just hugs for your code)
Gary Trakhman
 
PDF
## Introducing a reactive Scala-Akka based system in a Java centric company
Milan Aleksić
 
PDF
Clojure made-simple - John Stevenson
JAX London
 
PDF
Clojure 1.1 And Beyond
Mike Fogus
 
PDF
Clojure class
Aysylu Greenberg
 
PDF
Introductory Clojure Presentation
Jay Victoria
 
PDF
A Java Developers first Clojure project
Craig Malone
 
ODP
Clojure made simple - Lightning talk
John Stevenson
 
Introduction to Clojure
Renzo Borgatti
 
5 little clojure functions
Diego Pacheco
 
Getting started with Clojure
John Stevenson
 
Clojure for Java developers
John Stevenson
 
The Ideas of Clojure - Things I learn from Clojure
Hsuan Fu Lien
 
Clojure Programming Cookbook Makoto Hashimoto Nicolas Modrzyk
mbouemugnia
 
HelsinkiJS - Clojurescript for Javascript Developers
Juho Teperi
 
Clojure made really really simple
John Stevenson
 
Clojure Fundamentals Course For Beginners
Paddy Lock
 
Functional (web) development with Clojure
Henrik Eneroth
 
Clojure+ClojureScript Webapps
Falko Riemenschneider
 
Clojure in real life 17.10.2014
Metosin Oy
 
'Getting' Clojure - '(parentheses are just hugs for your code)
Gary Trakhman
 
## Introducing a reactive Scala-Akka based system in a Java centric company
Milan Aleksić
 
Clojure made-simple - John Stevenson
JAX London
 
Clojure 1.1 And Beyond
Mike Fogus
 
Clojure class
Aysylu Greenberg
 
Introductory Clojure Presentation
Jay Victoria
 
A Java Developers first Clojure project
Craig Malone
 
Clojure made simple - Lightning talk
John Stevenson
 
Ad

Recently uploaded (20)

PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 

Wrapping java in awesomeness aka condensator

  • 1. WRAPPING JAVA IN AWESOMENESS CONDENSATOR REACTIVE COMMUNICATION OVER TCP
  • 2. TERO KADENIUS (@PISKETTI) Clojure enthusiast, recovering Java programmer JUHA HEIMONEN (@EVILBUBU) Clojure N00b We are part of Flowa (@FlowaWolf)
  • 3. FIRST THINGS FIRST Infrastructure of what you currently see
  • 4. WAIT... Let's see if we can attach another crucial part Executed function: (defn attach-command-listener! [] (condensator/on c "command" (fn [{data :data}] (case data "right" (right-sound) "left" (left-sound) nil)) {:address address :port port}))
  • 5. NOW IT IS LIKE THIS. New Infrastructure view
  • 7. WE CAN SEND MESSAGES OTHER WAY AROUND
  • 8. WHAT? Condensator = Spring Reactor (Java) Meltdown (Awesome Clojure by Clojurewerkz)
  • 9. CONDENSATOR CONTAINS TCP messaging capability on top of Spring Reactor and Meltdown (by Clojurewerkz). So in overall, you get a system that implements Reactor pattern with TCP transport.
  • 10. REACTOR PATTERN Event handling pattern Synchronous dispatching of events (Executes when it's possible to do so without blocking) Coarserly concurrent, doesn't use multiple threads
  • 11. API (defn create "Creates condensator based on meltdown or tcp capable condensator" ([address port]) ([])) (defn notify "Notifies condensator with payload based on selector" ([condensator selector payload]) ([selector payload {:keys [address port]}])) (defn on "Attaches listener to condensator" ([condensator selector cb]) ([condensator selector cb {:keys [address port]}])) (defn receive-event [condensator selector cb]) (defn send-event [condensator selector data cb])
  • 12. WHY BUILD ON TOP OF A JAVA LIBRARY?
  • 13. NO NEED TO REINVENT THE WHEEL THERE ARE A LOT OF STUFF WRITTEN IN JAVA ALREADY MATURITY - QUITE A BIT OF JAVA STUFF IS BATTLE TESTED FOR YOU
  • 14. USING A JAVA LIBRARY DIRECTLY CAN BE A BIT...
  • 15. (let [calculator (FooCalculator.) inputBean (doto (InputBean.) (.setFoo (Integer. 1)) (.setBar (Integer. 2)) (.setBaz (Integer. 3)))] (.setInput calculator inputBean) (.performCalculation calculator) (let [resultBean (.getCalculationResultBean calculator) subresultA (.getSubresultA resultBean) subresultB (.getSubresultB resultBean)] ;; Do something with the result ))
  • 16. (let [{:keys [subresult-a subresult-b]} (calc {:foo 1 :bar 2 :baz 3})] ;; Do something with the result )
  • 17. RANDOM LEARNINGS... Shape of an API matters (Clojure ones tend to be simple. Big surprise!) "Clojure is not for geniuses" -Adam Bard "idiot-friendly design" -Adam Bard
  • 18. RANDOM LEARNINGS CONTINUED Wrapping Java to Clojure is pretty much controlling mutability and restricting state (def c (condensator/create)) ... (condensator/on c "command" (fn [{data :data}] ...) Restrict mutable java to one instance, pass it with immutable data to clojure API
  • 19. RANDOM LEARNINGS CONTINUED #2 Testing asynchronous stuff is surprisingly simple with promises (it "remote notifies and locally executes listener" (let [datapromise (promise)] (condensator/on server "remote" (fn [data] (info datapromise) (deliver datapromise (:data data)))) (tcp/send-tcp-msg :port 3030, :operation :notify, :selector "remote", :data "from-remote") (let [result (deref datapromise 3000 nil)] (should= "from-remote" result)))) A daily dose of Clojure increases programmer happiness by 63%