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:

  1. Bulkhead.Metrics#getQueueDepth() — the number of permission requests currently waiting (default 0, so custom Bulkhead implementations are unaffected). Exposed by the Micrometer binder as resilience4j.bulkhead.queue.depth next to available.concurrent.calls / max.allowed.concurrent.calls, and by the Dropwizard adapter.
  2. BulkheadConfig#queueCapacity — the maximum number of waiting permission requests. The default Integer.MAX_VALUE keeps today's behavior; when the queue is full, further asynchronous requests fail immediately with BulkheadFullException and publish CallRejected, exactly like a full ThreadPoolBulkhead queue. Wired through CommonBulkheadConfigurationProperties (Spring Boot / Micronaut) and the commons-configuration adapter. The blocking acquirePermission() / 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