Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circuit breaker and kill switch not working #2229

Closed
stormaref opened this issue Jan 8, 2021 · 11 comments
Closed

Circuit breaker and kill switch not working #2229

stormaref opened this issue Jan 8, 2021 · 11 comments

Comments

@stormaref
Copy link

stormaref commented Jan 8, 2021

Is this a bug report?

Yes

Can you also reproduce the problem with the latest version?

Yes

Environment

  1. Dotnet version: 5
  2. Operating system: Windows 10
  3. IDE (Rider, VS Code, Visual Studio): Visual Studio
  4. Rabbitmq 3

Steps to Reproduce

(Write your steps here:)

  1. Add service in startup.cs
  2. Use circuit breaker or kill switch in endpoint configuration

Expected Behavior

After the circuit breaker opened the request shouldn't be processes by consumer and throw an exception immediately

Actual Behavior

Request is not processing by consumer but it doesn't throw an exception immediately instead it just wait for a long time before throwing exception

@phatboyg
Copy link
Member

phatboyg commented Jan 8, 2021

Without code, or an example, I'll close this issue.

And you shouldn't use both Circuit Breaker and Kill Switch together, Circuit Breaker doesn't make sense with message consumers.

@phatboyg phatboyg added the Close Pending Will be closed soon lacking any further updates label Jan 8, 2021
@stormaref
Copy link
Author

I didn't use them both at one time I tried them separately and I'll send you an example tomorrow

@phatboyg
Copy link
Member

phatboyg commented Jan 8, 2021

Okay. It's been tested and works with every transport, you can see the configuration in the unit tests. So if it isn't working, verify that you've configured it correctly.

@stormaref
Copy link
Author

stormaref commented Jan 9, 2021

RabbitMQTest
you can see an example in this repository where apione publish a message and wait for response but apitwo (the consumer) always throw an exception and when kill switch get enabled it does not immediately throw an exception and instead it just wait for timeout

@phatboyg
Copy link
Member

phatboyg commented Jan 9, 2021

If the consumer in ApiTwo is throwing exceptions, the Kill Switch will stop the endpoint and wait one minute before restarting it. If you make any requests using the request client during the time the receive endpoint is stopped, they would of course timeout as there isn't a consumer available to respond (that endpoint is stopped).

So, it's working as intended.

@phatboyg phatboyg added move-to-discussion and removed Close Pending Will be closed soon lacking any further updates labels Jan 9, 2021
@stormaref
Copy link
Author

So what should I do if I want to get an exception immediately when consumer is unavailable?

@phatboyg
Copy link
Member

phatboyg commented Jan 9, 2021

Immediately? That's a bit of an extreme demand, considering distributed systems. If you want an immediate failure when a remote endpoint is unavailable, stick to HTTP or gRPC that require an immediate connection.

The request client doesn't know if an endpoint is consuming messages or not, it sends a message and waits for a response. If the timeout is reached, the request client throws a RequestTimeoutException. So your adjustment is that timeout, but setting it too short is sort of pointless, and you might as well use HTTPClient to call an API endpoint.

It goes back to the age old question of when do you use messaging for RPC, versus a non-durable transport like HTTP when there are no side effects produced by the message being consumed.

@stormaref
Copy link
Author

stormaref commented Jan 10, 2021

That's exactly what a circuit breaker must do
Return exception immediately when it's open

@phatboyg
Copy link
Member

You'd need the circuit breaker on the client side, before the request client. A circuit breaker on the consumer side would be worthless.

@stormaref
Copy link
Author

yes I should do use it on client side
thanks for your help and your nice package it really made it easy to work with the rabbitmq

@stormaref
Copy link
Author

maybe you want to keep it open for other users too see

@stormaref stormaref reopened this Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants