SlideShare a Scribd company logo
Using Zeebe with Spring Boot
and Apache Camel
CamundaCon 2018 - Jan Galinski
@holisticon @jangalinski
About me
■ Jan Galinski (Holisticon AG)
■ github.com/jangalinski
Agenda
■ What is ...
□ ... Zeebe?
□ ... spring-zeebe?
□ ... Apache Camel?
□ ... camel-zeebe?
■ Live Demo: facebam
■ Conclusion
what you won't see
■ Docker
■ kafka/rabbitMQ
■ serverless
I am sorry!
Workflow Engine for Microservices Orchestration
http://zeebe.io
zeebe
■ developed by camunda
■ decentralized process engine
■ orchestration of microservices
■ current version 0.11.0 (release planned
2019/Q1)
■ Broker and Client API
"Spring on steroids"
http://start.spring.io
spring boot
■ developed by pivotal
■ current version 2.0.5 (2018/09)
■ annotation based
■ opinionated - convention over configuration
■ "starter" concept
■ executable jars
Hello World!
mvn spring-boot:run
@SpringBootApplication
@RestController
public class MyApplication {
public static void main(String... args) {
SpringApplication.run(MyApplication.class, args);
}
@GetMapping("/")
public String hello() {
return "hello World";
}
}
spring-zeebe
■ "Requested" by Bernd
■ First Release End 2017
■ can run broker and clients
■ yaml based configuration
■ allows annotation based subscriptions
■ current version: 0.3.0-SNAPSHOT
https://github.com/zeebe-io/spring-zeebe
Example: spring-zeebe-
starter
@SpringBootApplication
@EnableZeebeClient
public class WorkerApplication {
public static void main(final String... args) {
SpringApplication.run(WorkerApplication.class, args);
}
@ZeebeWorker(taskType = "sayHello")
public void sayHello(final JobClient client, final JobEvent job) {
client.newCompleteCommand(job)
.payload("{"hello": "world"}")
.send().join();
}
}
Route based enterprise integration framework
http://camel.apache.org/
Apache Camel
■ Apache Foundation Open Source
■ First commit 2007 (!)
■ Implements Enterprise Integration Patterns
■ 200+ production ready components
■ (almost) any transport protocol
CamundaCon 2018: Using Zeebe with Spring Boot and Apache Camel (Holisticon)
Camel building blocks
A Route
■ defines a data flow
■ starts with an Endpoint
■ can have (multiple) Processors modifying
data
■ ends with an Endpoint
Camel building blocks
An Endpoint
Is either a ...
■ Consumer - starts a route, creates an
Exchange
or a
■ Producer - ends a route, exposes Exchange
Camel building blocks
A Component
■ provides a name-space (file://folder)
■ is a factory for Endpoints
Camel building blocks
An Exchange
■ represents data in a Route
■ encloses Messages (In and Out)
■ Messages have a Header (Map) and a Body
Route Example
// subscribe to topic
from("activemq:topic?[options]")
.filter(doSomeFiltering())
// call a processor-method
.process(convertToPojo())
// process input using spring service
.bean(TheBusinessService.class)
// write csv
.marshal().csv()
// store result on server
.to("ftp:host?[options]")
Camel Zeebe
work in progress
https://github.com/holunda-io/camel-zeebe
Motivation
■ Do not assume that worker can connect to
broker via tcp
■ do not require worker to speak "zeebe"
■ support any worker language
■ support any messaging protocol
Camel Zeebe API
■ immutable Commands and Events
■ no dependency on zeebe-lib
■ Supports
□ Register Self
□ Start Process
□ Complete Job
□ ...
Camel Zeebe API
data class StartProcessCommand(
val bpmnProcessId: String,
val payload: Json? = null
)
interface StartProcessGateway {
companion object { const val ENDPOINT = "direct:startProcess" }
fun send(command: StartProcessCommand)
}
startProcessGateway.send(StartProcessCommand("process_dummy", <payloadJson>))
Camel Zeebe Core
■ Zeebe Client connected to Broker
■ Camel Component defining zeebe://...
■ Provides Endpoints to
□ Register Worker
□ Start Process
□ Complete Job
□ ...
Camel Zeebe Core
class ProcessStartEndpoint(context: ZeebeComponentContext) : ZeebeProducerOnlyEndpoint(...) {
override fun createProducer(): Producer = object : DefaultProducer(this) {
override fun process(exchange: Exchange) {
val cmd = exchange.getIn().getMandatoryBody(StartProcessCommand::class.java)
context.workflowClient
.newCreateInstanceCommand()
.bpmnProcessId(cmd.bpmnProcessId)
.latestVersion()
.payload(cmd.payload)
.send()
.join()
}
}
}
Demo
Zeebe Camel Facebam
https://github.com/holunda-io/zeebe-camel-
facebam
Architecture
Dynamic
>
  Let there be code  
   
Now you tell me:
Was that cool or what?
But wait ...
... there is more
Everyone!
Take a picture
and mail it to:
holunda.io@gmail.com
Conclusion
What just happened
■ Zeebe Broker does not know workers
■ Workers do not use Zeebe-API
■ Only Orchestrator is connected to Broker
■ Camel routes connect everything
What we could do
■ replace file system with messaging
infrastructure
■ any camel supported route will work out of the
box
■ any program that can write/read the JSON-API
can be a worker
■ Test routes by mocking components
But wait ...
... ah, no - that was it!
Thank you
Simon Zambrovski
Simon Sprünker

More Related Content

CamundaCon 2018: Using Zeebe with Spring Boot and Apache Camel (Holisticon)

  • 1. Using Zeebe with Spring Boot and Apache Camel CamundaCon 2018 - Jan Galinski @holisticon @jangalinski
  • 2. About me ■ Jan Galinski (Holisticon AG) ■ github.com/jangalinski
  • 3. Agenda ■ What is ... □ ... Zeebe? □ ... spring-zeebe? □ ... Apache Camel? □ ... camel-zeebe? ■ Live Demo: facebam ■ Conclusion
  • 4. what you won't see ■ Docker ■ kafka/rabbitMQ ■ serverless I am sorry!
  • 5. Workflow Engine for Microservices Orchestration http://zeebe.io
  • 6. zeebe ■ developed by camunda ■ decentralized process engine ■ orchestration of microservices ■ current version 0.11.0 (release planned 2019/Q1) ■ Broker and Client API
  • 8. spring boot ■ developed by pivotal ■ current version 2.0.5 (2018/09) ■ annotation based ■ opinionated - convention over configuration ■ "starter" concept ■ executable jars
  • 9. Hello World! mvn spring-boot:run @SpringBootApplication @RestController public class MyApplication { public static void main(String... args) { SpringApplication.run(MyApplication.class, args); } @GetMapping("/") public String hello() { return "hello World"; } }
  • 10. spring-zeebe ■ "Requested" by Bernd ■ First Release End 2017 ■ can run broker and clients ■ yaml based configuration ■ allows annotation based subscriptions ■ current version: 0.3.0-SNAPSHOT https://github.com/zeebe-io/spring-zeebe
  • 11. Example: spring-zeebe- starter @SpringBootApplication @EnableZeebeClient public class WorkerApplication { public static void main(final String... args) { SpringApplication.run(WorkerApplication.class, args); } @ZeebeWorker(taskType = "sayHello") public void sayHello(final JobClient client, final JobEvent job) { client.newCompleteCommand(job) .payload("{"hello": "world"}") .send().join(); } }
  • 12. Route based enterprise integration framework http://camel.apache.org/
  • 13. Apache Camel ■ Apache Foundation Open Source ■ First commit 2007 (!) ■ Implements Enterprise Integration Patterns ■ 200+ production ready components ■ (almost) any transport protocol
  • 15. Camel building blocks A Route ■ defines a data flow ■ starts with an Endpoint ■ can have (multiple) Processors modifying data ■ ends with an Endpoint
  • 16. Camel building blocks An Endpoint Is either a ... ■ Consumer - starts a route, creates an Exchange or a ■ Producer - ends a route, exposes Exchange
  • 17. Camel building blocks A Component ■ provides a name-space (file://folder) ■ is a factory for Endpoints
  • 18. Camel building blocks An Exchange ■ represents data in a Route ■ encloses Messages (In and Out) ■ Messages have a Header (Map) and a Body
  • 19. Route Example // subscribe to topic from("activemq:topic?[options]") .filter(doSomeFiltering()) // call a processor-method .process(convertToPojo()) // process input using spring service .bean(TheBusinessService.class) // write csv .marshal().csv() // store result on server .to("ftp:host?[options]")
  • 20. Camel Zeebe work in progress https://github.com/holunda-io/camel-zeebe
  • 21. Motivation ■ Do not assume that worker can connect to broker via tcp ■ do not require worker to speak "zeebe" ■ support any worker language ■ support any messaging protocol
  • 22. Camel Zeebe API ■ immutable Commands and Events ■ no dependency on zeebe-lib ■ Supports □ Register Self □ Start Process □ Complete Job □ ...
  • 23. Camel Zeebe API data class StartProcessCommand( val bpmnProcessId: String, val payload: Json? = null ) interface StartProcessGateway { companion object { const val ENDPOINT = "direct:startProcess" } fun send(command: StartProcessCommand) } startProcessGateway.send(StartProcessCommand("process_dummy", <payloadJson>))
  • 24. Camel Zeebe Core ■ Zeebe Client connected to Broker ■ Camel Component defining zeebe://... ■ Provides Endpoints to □ Register Worker □ Start Process □ Complete Job □ ...
  • 25. Camel Zeebe Core class ProcessStartEndpoint(context: ZeebeComponentContext) : ZeebeProducerOnlyEndpoint(...) { override fun createProducer(): Producer = object : DefaultProducer(this) { override fun process(exchange: Exchange) { val cmd = exchange.getIn().getMandatoryBody(StartProcessCommand::class.java) context.workflowClient .newCreateInstanceCommand() .bpmnProcessId(cmd.bpmnProcessId) .latestVersion() .payload(cmd.payload) .send() .join() } } }
  • 29. >   Let there be code      
  • 30. Now you tell me: Was that cool or what?
  • 31. But wait ... ... there is more
  • 32. Everyone! Take a picture and mail it to: holunda.io@gmail.com
  • 34. What just happened ■ Zeebe Broker does not know workers ■ Workers do not use Zeebe-API ■ Only Orchestrator is connected to Broker ■ Camel routes connect everything
  • 35. What we could do ■ replace file system with messaging infrastructure ■ any camel supported route will work out of the box ■ any program that can write/read the JSON-API can be a worker ■ Test routes by mocking components
  • 36. But wait ... ... ah, no - that was it!