제가 한번 패턴을 만들어 봤습니다 ㅋㅋ
약간 어그로이고 토픽 수신 받아 비동기+순차적 처리를 하고 실패와 성공에 대한 결과에 따라 처리하기 위해 고민하다가 실패 지점부터 정확히 재시도 하거나 회복 불가능한 상태라면 바로 실패 처리 가능하도록 메서드 조합해보았는데 나름 뿌듯해서요 ㅎㅎ

@startuml
!theme vibrant
title Asynchronous Workflow Engine Sequence Diagram
actor KafkaListener
participant MinioUserEventHandler as Handler
participant UserJpaRepository as UserRepo
participant RequiredActionStore as ActionStore
participant MinioAccountService as MinioSvc
participant DB
KafkaListener -> Handler: eventToEntity(event, ack)
activate Handler
== Initialization Transaction (Synchronous) ==
Handler -> UserRepo: persistUser(entity)
activate UserRepo
UserRepo -> DB: INSERT UserEntity, EventLog
UserRepo -> ActionStore: addRegisterAction(entity)
activate ActionStore
ActionStore -> DB: INSERT RequiredAction(s)
deactivate ActionStore
UserRepo --> Handler: persistedEntity
deactivate UserRepo
== Asynchronous Workflow Execution ==
Handler -> Handler: addMinioUserCompletable(entity, ack)
note right of Handler: Returns CompletableFuture immediately.\nKafkaListener thread is now free.
KafkaListener <-- Handler: (return)
deactivate Handler
note over Handler: Workflow executes in background thread pool
loop For each pending action from DB
Handler -> MinioSvc: minioAddUserCompletableFuture(entity)
activate MinioSvc
MinioSvc --> Handler: (CompletableFuture<Void>)
deactivate MinioSvc
Handler -> ActionStore: updateTask(entity, "MINIO_ADD_USER", true)
activate ActionStore
ActionStore -> DB: UPDATE RequiredAction
deactivate ActionStore
Handler -> MinioSvc: createObjectPathCompletableFuture(entity)
activate MinioSvc
MinioSvc --> Handler: (CompletableFuture<Void>)
deactivate MinioSvc
Handler -> ActionStore: updateTask(entity, "MINIO_ADD_PATH", true)
activate ActionStore
ActionStore -> DB: UPDATE RequiredAction
deactivate ActionStore
end
== Finalization ==
Handler -> UserRepo: updateUser(entity)
activate UserRepo
UserRepo -> DB: UPDATE UserEntity (e.g., set activate=true)
deactivate UserRepo
Handler -> KafkaListener: ack.acknowledge()
note right of Handler: All steps completed successfully.
@enduml
```댓글을 남기려면 로그인이 필요합니다.
로그인 후 이 페이지로 돌아와 바로 댓글을 남길 수 있습니다.