Spring / Resilience4j Interview questions
How does RegistryEventConsumer work in Resilience4j?
RegistryEventConsumer lets code react to changes at the registry level - when a CircuitBreaker (or Retry, Bulkhead, etc.) instance is added, removed, or replaced in its registry - rather than reacting to individual call events on one specific instance.
It's implemented by overriding onEntryAddedEvent, onEntryRemovedEvent, and onEntryReplacedEvent, then passed into the registry's builder; a common use is automatically attaching per-instance event logging or metrics binding to every CircuitBreaker the moment it's created, so newly added instances - including ones added dynamically at runtime - don't need to be wired up manually one by one.
This is distinct from a CircuitBreaker's own EventPublisher, which only reports events (state transitions, successes, failures) for that single already-existing instance.
More Related questions...