Files
DoksanbirandIlkka Seppälä 4cabb204f2 feat: add Microservices Bulkhead pattern (#3228) (#3597)
* feat: add Microservices Bulkhead pattern (#3228)

* fix: cancel queued calls on bulkhead shutdown

Shutdown now cancels the queued futures so callers do not hang, a shutdown racing a submit is no longer counted as a rejection, and interrupted inventory checks are logged. The class diagram is a rendered PNG.

---------

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
2026-09-13 09:53:54 +03:00

54 lines
1.4 KiB
Plaintext

@startuml
package com.iluwatar.bulkhead {
interface RemoteService {
+ call(request : String) : String {abstract}
}
class Bulkhead {
- name : String
- maxConcurrentCalls : int
- maxQueueSize : int
- executor : ThreadPoolExecutor
- rejectedCalls : AtomicLong
+ Bulkhead(name : String, maxConcurrentCalls : int, maxQueueSize : int)
+ submit(task : Callable<T>) : Future<T>
+ getName() : String
+ getMaxConcurrentCalls() : int
+ getMaxQueueSize() : int
+ getActiveCalls() : int
+ getQueuedCalls() : int
+ getRejectedCalls() : long
+ shutdown() : void
+ close() : void
}
class BulkheadFullException {
- bulkheadName : String
+ BulkheadFullException(bulkheadName : String)
+ getBulkheadName() : String
}
class PaymentService {
- latency : Duration
+ PaymentService(latency : Duration)
+ call(request : String) : String
}
class InventoryService {
+ InventoryService()
+ call(request : String) : String
}
class App {
- PAYMENT_LATENCY : Duration {static}
- WAIT_TIMEOUT : Duration {static}
+ App()
+ main(args : String[]) : void {static}
}
}
Bulkhead ..|> AutoCloseable
BulkheadFullException --|> RuntimeException
PaymentService ..|> RemoteService
InventoryService ..|> RemoteService
Bulkhead ..> BulkheadFullException
App ..> Bulkhead
App ..> PaymentService
App ..> InventoryService
App ..> BulkheadFullException
@enduml