SemaphoreBulkhead: expose the depth of the permission queue and allow bounding it
Author: o-shevchenkoCreated Sep 23, 2026Updated Sep 23, 2026
Resilience4j version: master after #2506 (2.4.1-SNAPSHOT)
Java version: 21
Follow-up to #1592 / #2506. Since #2506 a SemaphoreBulkhead with maxWaitDuration > 0 queues asynchronous permission requests (acquirePermissionAsync(), Reactor operator). That queue is bounded only by time (maxWaitDuration) and its depth is not observable. @RobWin's original sketch in #1592 used a bounded queue of permission requests, so this closes the remaining gap to that design.
Proposal, mirroring the ThreadPoolBulkhead naming:
Bulkhead.Metrics#getQueueDepth()— the number of permission requests currently waiting (default0, so customBulkheadimplementations are unaffected). Exposed by the Micrometer binder asresilience4j.bulkhead.queue.depthnext toavailable.concurrent.calls/max.allowed.concurrent.calls, and by the Dropwizard adapter.BulkheadConfig#queueCapacity— the maximum number of waiting permission requests. The defaultInteger.MAX_VALUEkeeps today's behavior; when the queue is full, further asynchronous requests fail immediately withBulkheadFullExceptionand publishCallRejected, exactly like a fullThreadPoolBulkheadqueue. Wired throughCommonBulkheadConfigurationProperties(Spring Boot / Micronaut) and the commons-configuration adapter. The blockingacquirePermission()/tryAcquirePermission()paths are unaffected: they wait on the semaphore, not in the queue.
I am preparing a PR and will reference this issue.
Source: resilience4j/resilience4j