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
- 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!
- 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
- 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
- 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
- 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]")
- 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()
}
}
}
- 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