I have a SpringBoot application which has circuitBreaker implemented with annotations. The annotated circuitbreaker is an Aspect so that the client doesnt have to explicitly annotate their methods with the circuitBreaker annotation.When I hit the RequestMapping from the browser in high frequency the circuitbreaker settings are getting applied and the fallback is getting called.
Issue is when I try to test this from the Test class by calling the api using concurrent threads. As the api is down the fallback mechanism kicks in but the config settings of the circuit breaker doesnt come into picture. Also same is the behavior when multiple requests are called from Postman.
Related
I'm using Spring's WebClient in a non-reactive application to make requests to a third-party service that uses OAuth2 client credentials for its security.
I would like to have http.client.requests related metrics for the OAuth2 requests that are made, however (as best I can tell) this isn't happening because DefaultClientCredentialsTokenResponseClient creates its own instance of RestTemplate using the constructor, instead of leveraging an injected RestTemplateBuilder, which would handle the instrumentation automatically.
Is there a way to have these metrics surfaced by Micrometer?
I'm exploring Istio's circuit breaker and wan't to setup fallback methods if the circuit trips.
I have a few Spring boot applications that are deployed on kubernetes and with Istio's circuit breaking defined in DestinationRule.
I can see that my caller application gets a 503 Service Unavailable exception when I intentionally bring down the called service.
I'm looking for design patterns or libraries with which I can define fallback methods for my rest calls,
something similar to #HystrixCommand.
I checked out spring-cloud-circuitBreaker but that doesn't support Istio.
I have also explored ClientHttpRequestInterceptor with Spring RestTemplate, and can catch all ServiceUnavailable exceptions, but I need a way to configure different fallback methods to different REST calls.
Any suggestion is appreciated.
I have an api(API 1) which is being stubbed through MockMvc.When I post on this API through this mock object, a request goes out to external system which in turn invokes api (API 2) of my system. Since this API 2 is invoked through http channel (host:port) and the container is not running, this breaks. How do I handle this scenario since I would not prefer to change the way external system invokes my API. Hope I have clarified.
If you're using MockMvc, you cannot test calls over the network.
So in that case, you would need to mock or stub the components that perform external network calls.
On the other hand, if you are using Spring Boot... you can then have Spring Boot's testing support launch the embedded Servlet container for the test, and externals calls can connect to the running Servlet container over HTTP. For that however, you would typically use something like Spring Boot's TestRestTemplate or core Spring's WebTestClient (available since Spring Framework 5.0) instead of MockMvc.
I have a spring cloud project with the following packaging structure
Controller (publishes Rest Endpoint)-->flow (business logic)-->service (calls Feign client with hysterix fallback setup )--> Feign client.
Auto-wiring is done in respective classes e.g. flow is auto-wired in controller and service is auto-wired in flow and so on.
I want to perform integration test, by calling the endpoint published by the controller. The problem is I don't have endpoint accessed by the feign client at the moment (neither original nor spring cloud contract stub is available).
How do I stub the call made by feign client in this case.
You can use Spring Cloud WireMock support and set up an endpoint manually before the tests are called. In the feign configuration you can point manually to an IP and port. The problem is that this test is pretty much useless cause as a consumer you're mocking the producer.
UPDATE
You have a Feign client that will be used to call some external API. What you can do is you can use Spring Cloud WireMock (or just WireMock) to setup a mock of that API. Then you can teach WireMock to behave as you wish and assert whether your client works fine. The problem with such an approach is such that since you, as a client, are setting up the WireMock instance, you can teach it to behave in the way that has nothing to do with the real API. For example you state that if you send a request to endpoint /foo with a method GET then you should get back "BAR" in the response. Then you write a test where your client sends GET # /foo and assert that BAR got properly returned. However that doesn't mean that the other API indeed has that endpoint. So this approach can give you false-positives. You can however use WireMock to assert whether you can properly react to faulty responses like malformed response etc.
In such cases, if you really want to check if you can communicate properly with an API that you don't control, is that you can write tests that will call that real API via a WireMock proxy, you record that traffic and convert it into stubs. You can watch about this more in my presentation here https://www.youtube.com/watch?v=ZyHG-VOzPZg
My spring boot(1.3.5) application uses couchbase(2.0) and exposes rest controller. I can access data from couchbase and browser shows it as a response. NO issues here.
Now I want to use ehcache. When I add #EnableCaching in the main application class, rest service stops working. In the logs it says 'did not find any matchers for the request'
https://github.com/maverickmicky/spring-couchbase-cache