Flux is a Highly scalable Event-driven, Reactive system for building Stateful apps and Workflow services. It is an open source project from Flipkart. It is available at https://github.com/flipkart-incubator/flux.
2. What is a Workflow?
Set of tasks which need to complete sequentially or parallelly to achieve a business goal
3. Why Workflows?
● Better Insights
● To stitch tasks which coordinate work across multiple components
| long-running | may fail | time-out | require restarts
4. Flux
Is
● An Asynchronous, Distributed and Reliable state machine based orchestrator
● Used to build Stateful event-driven apps and workflows.
● Simple - Primitives, Deployment dependencies
5. Flux - Reactive, Event-driven
User
triggered
events
Flux
generated
events
Database
update
events
System
generated
events
Resources
Downstream
Systems
7. Few Rules
● All params and return values should implement Event interface
● Stateless Classes
● Immutable event objects in workflow method
● Workflow method must return void
9. Execution
when Workflow method is invoked in client environment, Flux client library intercepts the call and generates workflow
skeleton on the fly and submits the request to Flux runtime for execution.
10. Testability
● Unit and Integration Testing
○ As workflows are written in Java, Unit and Integration testing would be similar to writing them for
any other Java code
● Debugging through IDE
○ You can attach a debugger to Flux process to debug the workflow while development. Find more
details about it on https://github.com/flipkart-incubator/flux/wiki/Examples.
● Toggling between Async and Sync
○ Removing “FluxClientInterceptorModule” from your Guice Injector lets your code to run in Sync
mode. With this you can toggle between Async and Sync whenever you want.
15. ● Guarantees atleast-once execution of Tasks
○ Using durable states, transitions, events
● Local retries for timed-out executions and on Retriable exception
○ For @Task instances with ‘retries’ and ‘timeout’ attribute values - Retries executed on the
same Flux node
● Global retries for stalled state transitions using Redriver
○ For @Task instances with ‘retries’ and ‘timeout’ attribute values - Retries executed on any of
the Flux cluster nodes
Fault tolerance
16. When a seller initiated pack, we need to call and update various systems. Downstream systems involved are
1. Vendor Assignor - this generates a tracking id which has to be shown on the label printed on the shipment.
2. Accounting - to generate invoices and various other accounting entries
3. Doc Service - this creates a PDF consisting of the label and the invoice which has to be printed and attached in the shipment.
4. Logistics Compliance Engine - to generate various government forms required when a shipment has to cross state borders.
Flux orchestration is used in above scenarios.
Use Cases - Seller Fulfilment Service
17. Use Cases - outside FK
Tele-consultation service workflow of Helthface/Curefit. Actively running on AWS.
18. Use Cases - Helthface/Curefit - Health checkup using 3rd party provider
19. Feature Set
State Management
Async and Distributed processing
Fork & Join
Parallel processing
Correlation Id support
Retriable Errors
Configurable Retries & Timeouts
Versioning of workflows
At least once guarantees
Idempotency at workflow level
External and Scheduled events
Cancellation of ongoing Workflow
Metrics & Audit
Nested workflows
Dynamic conditional branching