Reputation: 2707
When using CircuitBreaker with RabbitMq like so:
sbc.ReceiveEndpoint(host, "IDocumentImported_Warehouses.Nls", ep => {
ep.Consumer(() => _container.Resolve<DocumentConsumer>());
ep.PrefetchCount = 1;
ep.UseCircuitBreaker(cb => {
cb.ResetInterval = TimeSpan.FromSeconds(10);
cb.ActiveThreshold = 1;
cb.TrackingPeriod = TimeSpan.FromSeconds(10);
});
});
});
The DocumentConsumer correctly does not receive further messages however MassTransit will still consume all the messages from RabbitMq and put them into the error queue. Is this expected behaviour? The documentation doesn't cover too much.
Upvotes: 2
Views: 1821
Reputation: 253
MassTransit introduced the "Kill Switch" in version 7.1.1.
A Kill Switch is used to prevent failing consumers from moving all the messages from the input queue to the error queue. By monitoring message consumption and tracking message successes and failures, a Kill Switch stops the receive endpoint when a trip threshold has been reached.
Upvotes: 0
Reputation: 19640
I believe we cannot just stop the receiving endpoint. Circuit breaker is just a middleware, that fails proactively in case your consumer crashes over the threshold.
The meaning of circuit breaker is to allow the infrastructure behind failing consumer to recover and not get any more requests that can make it overloaded forever.
You can always consume the Fault<DocumentMessage>
and re-publish errored messages.
P.S. By the way, most container adapters support configuring consumers like this:
ep.Consumer<DocumentConsumer>(_container);
Upvotes: 0