Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Managing Business Processes in Microservice Arc...

Managing Business Processes in Microservice Architecture with Spring Ecosystem

Devoxx Poland 2019

Bartłomiej Słota

June 26, 2019
Tweet

More Decks by Bartłomiej Słota

Other Decks in Programming

Transcript

  1. BRUCE ➤ Software engineer ➤ 7 years of experience ➤

    Works on automating business processes ➤ Passionate about microservices ➤ Struggles to apply microservices into BPMS
  2. MICROSERVICES Autonomy Resilience Data Deployment Technology Scalability People App #1

    Source: www.trunkbaseddevelopment.com App #2 Source: www.leanpub.com/git-flow/read
  3. THE BUSINESS FLOW VS MICROSERVICES App #2 App #3 App

    #4 App #1 Based on: Alberto Brandolini EventStorming
  4. CONVENTION OVER CONFIGURATION @JsonSubTypes({ @JsonSubTypes.Type(name = „processInstanceCreated", value = ProcessInstanceCreated.class),

    @JsonSubTypes.Type(name = "processInstanceCancelled", value = ProcessInstanceCancelled.class), @JsonSubTypes.Type(name = "processInstanceCompleted", value = ProcessInstanceCompleted.class), @JsonSubTypes.Type(name = "taskCreated", value = TaskCreated.class), @JsonSubTypes.Type(name = "taskProcessingFailed", value = TaskProcessingFailed.class), @JsonSubTypes.Type(name = "taskCompleted", value = TaskCompleted.class), @JsonSubTypes.Type(name = "taskAssigned", value = TaskAssigned.class) }) public interface BPMEvent { }
  5. PROCESS ORCHESTRATION public interface AddressChangeProcessChannels { String ADDRESS_CHANGE_PROCESS_COMMANDS = "addressChangeProcessCommands";

    String ADDRESS_CHANGE_PROCESS_EVENTS = "processEvents"; @Input(ADDRESS_CHANGE_PROCESS_COMMANDS) SubscribableChannel addressChangeProcessCommands(); @Output(ADDRESS_CHANGE_PROCESS_EVENTS) MessageChannel addressChangeProcessEvents(); }
  6. PROCESS ORCHESTRATION public interface AccessVerificationChannels { String ACCESS_EVENTS = "accessEvents";

    String ACCESS_COMMANDS = "accessCommands"; @Input(ACCESS_EVENTS) SubscribableChannel accessEvents(); @Output(ACCESS_COMMANDS) MessageChannel accessCommands(); } public interface AddressChannels { String ADDRESS_EVENTS = "addressEvents"; String ADDRESS_COMMANDS = "addressCommands"; @Input(ADDRESS_EVENTS) SubscribableChannel addressEvents(); @Output(ADDRESS_COMMANDS) MessageChannel addressCommands(); } public interface AMLChannels { String ADDRESS_EVENTS = "amlEvents"; String ADDRESS_COMMANDS = "amlCommands"; @Input(ADDRESS_EVENTS) SubscribableChannel amlEvents(); @Output(ADDRESS_COMMANDS) MessageChannel amlCommands(); }
  7. HOW DO I KNOW THAT THE SERVICE ANSWERS TO MY

    PROCESS? ➤ Add the header to every message in process manager ➤ Copy the header back with the response ignoring the content @JsonCreator public ProcessMetadata(@JsonProperty("processInstanceId") String processInstanceId, @JsonProperty("parentId") String parentId, @JsonProperty("processDefinitionId") String processDefinitionId) { this.processInstanceId = processInstanceId; this.parentId = parentId; this.processDefinitionId = processDefinitionId; } class AccessVerification { private final MessageChannel accessCommands; . . . private void sendVerifyAccessCommand(ProcessMetadata metadata, String clientId, String masterPassword) { final VerifyAccess verifyAccess = new VerifyAccess(clientId, masterPassword); accessCommands.send(MessageBuilder.withPayload(verifyAccess).copyHeaders(metadata.toMap()).build()); } }
  8. HOW DO I GET TASKS ASSIGNED TO A USER? KTable<User,

    Tasks> userTasks() { return streamsBuilder .stream(„processEvents”, Consumed.with(serdes.forA(String.class), serdes.forA(Task.class))) .groupBy((key, task) -> task.getUser(), Serialized.with(serdes.forA(User.class), serdes.forA(Task.class))) .aggregate(Tasks::empty, (TaskAggregator<User, Task, Tasks>) (user, task, tasks) -> tasks.add(task), materializedAs(„userTasks”)); }
  9. HOW DO I MONITOR MY PROCESSES? ➤ Spring Cloud Sleuth

    ➤ Zipkin ➤ ELK ➤ Prometheus ➤ Semantic monitoring
  10. ENTERPRISE INTEGRATION PATTERNS YOU WILL USE (SUB)CONSCIOUSLY ➤ Command message

    ➤ Event message ➤ Process manager ➤ Transactional client ➤ Event driven consumer ➤ Idempotent receiver ➤ …
  11. BPM - THE BUSINESS PERSPECTIVE REVISITED Process Modeler Common UI

    System integration Reporting N x Process Orchestrators