Does Feign retry require some sort of configuration? - spring-cloud

I just tried to do a attempted a seamless upgrade of a service in a test setup. The service is being accessed by a Feign client. And naively I was under the impression that with multiple instances available of the service, the client would retry another instance if it failed to connect to one.
That, however, did not happen. But I cannot find any mention of how Feign in Spring Cloud is supposed to be configured to do this? Although I have seen mentions of it supporting it (as opposed to using RestTemplate where you would use something like Spring Retry?)

If you are using ribbon you can set properties similar to the following (substituting "localapp" for your serviceid):
localapp.ribbon.MaxAutoRetries=5
localapp.ribbon.MaxAutoRetriesNextServer=5
localapp.ribbon.OkToRetryOnAllOperations=true

ps underneath Feign has a Retryer interface, which was made to support things like Ribbon.
https://github.com/Netflix/feign/blob/master/core/src/main/java/feign/Retryer.java

see if property works - OkToRetryOnAllOperations: true
You can refer application ->
https://github.com/spencergibb/spring-cloud-sandbox/blob/master/spring-cloud-sandbox-sample-frontend/src/main/resources/application.yml
Spencer was quick...was late by few minutes :-)

Related

Communication between Microservices: Spring cloud OpenFeign vs WebClient/RestTemplate

Any idea please about the best way to use for back to back communication ?
spring cloud OpenFeign or WebClient/RestTemplate ?
I think Feign client should be used when spring cloud gateway need to
communicate to other microservices, whereas WebClient/RestTemplate should be used for back to back communication.
Am I wrong ?
WebClient (RestTemplate - deprecated to support WebClient)
Supports reactive call
underlying HTTP client libraries such as Reactor Netty
Part of spring framework - WebFlux || Doc will give you more
Comes in 2 flavour - Annotation and functional way
Personally I found it very useful while working with OAuth2 creating bean webClient, before making call it needs to be authenticated with token, ServerOAuth2AuthorizedClientExchangeFilterFunction will ease each call with just one time configuration
OpenFeign
Reactive - need to use 3rd party - com.playtika.reactivefeign
Fits best if you want call in blocking way
Part of Spring cloud
Netflix fully transferred Feign to the open-source community under a new project named OpenFeign

RestTemplate annotated by #LoadBalanced get wrong service address by service name from eureka sometimes

I use springcloud to build the system, including many microservices。 For some interface calls, I use resttemplate annotated by #LoadBalance to implement load balancing, and use eureka as a registry center. However, when I call interfaces between different micro services, resttemplate sometimes will connect to wrong service. For example, I have service A, B, C, when service A call a service B's interface, resttemplate annotated by #LoadBalance will find the actual ip&port from eureka by service name first, and then build the actual url and send the request to target server, but sometimes, it will find the service C's ip&port when I call service B's interface, which cause a fail invoking. This case occurs infrequently but nerver disappear, I have been troubled for a long time, could anyone give me some suggestions? Thanks.
I learned why yesterday: it is a bug in spring cloud Dalston.RELEASE(https://github.com/spring-cloud/spring-cloud-commons/issues/224), and we happen to use this version. Spring cloud had fixed this bug in Dalston.SR2, and now it works fine

Does Spring Cloud Feign client call execute inside hystrix command?

I'm configuring a sample application using this example:
http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance. In this section http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-ribbon it is said that:
Feign already uses Ribbon, so if you are using #FeignClient then this
section also applies
Does that mean that #FeignClient uses Hystrix too? Does the call to feign client execute inside hystrix command? if so, what is the proper way to pass hystrix configuration?
There are samples that wrap calls to feign client with #HystrixCommand. Is it a correct way?
There is an open ticket to support hystrix with feign. Currently, you need to wrap calls to feign clients with hystrix.
please use semaphore isolation:
hystrix:
command:
default:
execution:
isolation:
strategy: SEMAPHORE

Wildfly8: Server-level Remote IP Address filtering with Undertow?

How can I only allow requests from my Apache Server in the DMZ access to WildFly over AJP, and block everything else?
This answer works great at deployment level but I would prefer control at the server-level :
At the moment only way to do this is by implementing ServletExtension and add extra handlers that will take care of that.
see http://undertow.io/documentation/servlet/servlet-extensions.html for more on writing extensions
and example of using it:
https://github.com/undertow-io/undertow/blob/master/core/src/test/java/io/undertow/server/handlers/IPAddressAccessControlHandlerUnitTestCase.java
In any case I would encourage you to create new feature request in undertow jira to add proper support for this. Issue tracker can be found at: https://issues.jboss.org/browse/UNDERTOW

How to programmatically un/register POJOs as services in JBoss 4.2.3.GA

I need to be able to circumvent the whole deployer malarkey and programmatically register/unregister (dependency-less) POJOs as services in JBoss.
Currently I'm dynamically creating an MBean interface and registering this with the JBoss MBeanServer, and then registering local/remote with Jndi.
This works ok (I can have a standard service from a vanilla SAR reference one of these service POJOs with the #EJB annotation) - however the container seems to leaves stale references behind as after calling unbind() and unregisterMBean().
Obviously I'm missing something by not dealing with the container in a way it expects, but what am I missing? Or is there an easier way (can't see much in the way of an API)?
thanks.