These are chat archives for spring-cloud/spring-cloud

9th
May 2018
CH4:D
@chad_d_stud_twitter
May 09 2018 02:58
real slow in this group lately
Marcos Barbero
@marcosbarbero
May 09 2018 07:20
@chad_d_stud_twitter what do you want to achieve with this property exactly?
CH4:D
@chad_d_stud_twitter
May 09 2018 07:21
@marcosbarbero i was toying with how to change the “System Status” section of eureka. not sure if that’s the key to use
are you talking about the feign hystrix or data-center-info @marcosbarbero ?
Marcos Barbero
@marcosbarbero
May 09 2018 07:22
Well, you asked about eureka instance property
CH4:D
@chad_d_stud_twitter
May 09 2018 07:23
someone suggested i use that key
but when i enter it in application properties it tells me that key is not recognized
afaik, EnableFeignClients should achieve the same purpose
Marcos Barbero
@marcosbarbero
May 09 2018 07:24
To use this property you actually need to customize a bean in java code
If you are trying it by setting properties it won’t work as for the current implementation
if you need context
i would like to reiterate again that feign clients are working in our project. I’m trying to introduce a hystrix fallback behavior
Marcos Barbero
@marcosbarbero
May 09 2018 07:29
Let me check it out :)
CH4:D
@chad_d_stud_twitter
May 09 2018 07:31
cool
whoever developed feign clients should be given a nobel prize. i did something similar in an earlier framework. it was a pain to introduce new clients for each service we introduced :D
Marcos Barbero
@marcosbarbero
May 09 2018 09:50
@chad_d_stud_twitter I checked your stackoverflow question, I'm sure if I fully understand. Just to clarify, do you want to use Hystrix fallback in @FeignClient, is it?
CH4:D
@chad_d_stud_twitter
May 09 2018 10:39
yes
yes @marcosbarbero
Matthew Planchant
@mplanchant
May 09 2018 10:40
Hello all, I'd like to send logs from my Spring Boot application to AWS CloudWatch. What's a good starting point for this? I'm assuming I'll need some sort of Logback appender?
Marcos Barbero
@marcosbarbero
May 09 2018 11:23
So, based in the code you placed in stackoverflow I guess you probably misconfigured it. Did you check this fallback doc?
@chad_d_stud_twitter
CH4:D
@chad_d_stud_twitter
May 09 2018 11:25
this is the same one in the documentation
that first chunk of code
did i miss something? it’s basically identical with the names switched for my purpose
Marcos Barbero
@marcosbarbero
May 09 2018 11:28
Oops, my mistake. I was actually mentioning the FallbackFactory, did you try it?
CH4:D
@chad_d_stud_twitter
May 09 2018 11:29
not yet
wait, i’m just noticing this now
is that an inner class?
HystrixClientFallback is an inner class?
Marcos Barbero
@marcosbarbero
May 09 2018 11:30
in this example it is, I'm not sure if it actually makes any diff
but you can try it out :D
CH4:D
@chad_d_stud_twitter
May 09 2018 11:32
well my implementation was just a regular outer lass
CH4:D
@chad_d_stud_twitter
May 09 2018 11:40
still the same
com.netflix.client.ClientException: Load balancer does not have available server for client: myfeign
my first thought here is that does the hysterix fallback assume that the service have to be up first and that the fallback only happens if that specific endpoint has failed? @marcosbarbero
D D
@dosdebug
May 09 2018 11:43
HystrixClientFallback is an inner class?
It’s a static class so does not matter if it’s inner or not.
CH4:D
@chad_d_stud_twitter
May 09 2018 11:45
static class doesn’t work as an outer class
compiler error
@marcosbarbero i tried both variations of the code in the docs and still throws the same error
D D
@dosdebug
May 09 2018 11:49
@chad_d_stud_twitter Spring cloud release?
CH4:D
@chad_d_stud_twitter
May 09 2018 11:49
@dosdebug Finchley.RC1
Marcos Barbero
@marcosbarbero
May 09 2018 11:50
do you have any shareable project that reproduces the issue?
CH4:D
@chad_d_stud_twitter
May 09 2018 11:50
i also did it with no luck in m9
D D
@dosdebug
May 09 2018 11:50
for (String basePackage : basePackages) {
            Set<BeanDefinition> candidateComponents = scanner
                    .findCandidateComponents(basePackage);
            for (BeanDefinition candidateComponent : candidateComponents) {
                if (candidateComponent instanceof AnnotatedBeanDefinition) {
                    // verify annotated class is an interface
                    AnnotatedBeanDefinition beanDefinition = (AnnotatedBeanDefinition) candidateComponent;
                    AnnotationMetadata annotationMetadata = beanDefinition.getMetadata();
                    Assert.isTrue(annotationMetadata.isInterface(),
                            "@FeignClient can only be specified on an interface");

                    Map<String, Object> attributes = annotationMetadata
                            .getAnnotationAttributes(
                                    FeignClient.class.getCanonicalName());

                    String name = getClientName(attributes);
                    registerClientConfiguration(registry, name,
                            attributes.get("configuration"));

                    registerFeignClient(registry, annotationMetadata, attributes);
                }
            }
        }
See this, in the end, it tries to register feign client registerFeignClient(…)
And this is registerFeignClient implementation:
private void registerFeignClient(BeanDefinitionRegistry registry,
            AnnotationMetadata annotationMetadata, Map<String, Object> attributes) {
        String className = annotationMetadata.getClassName();
        BeanDefinitionBuilder definition = BeanDefinitionBuilder
                .genericBeanDefinition(FeignClientFactoryBean.class);
        validate(attributes);
        definition.addPropertyValue("url", getUrl(attributes));
        definition.addPropertyValue("path", getPath(attributes));
        String name = getName(attributes);
        definition.addPropertyValue("name", name);
        definition.addPropertyValue("type", className);
        definition.addPropertyValue("decode404", attributes.get("decode404"));
        definition.addPropertyValue("fallback", attributes.get("fallback"));
        definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory"));
        definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE);

        String alias = name + "FeignClient";
        AbstractBeanDefinition beanDefinition = definition.getBeanDefinition();

        boolean primary = (Boolean)attributes.get("primary"); // has a default, won't be null

        beanDefinition.setPrimary(primary);

        String qualifier = getQualifier(attributes);
        if (StringUtils.hasText(qualifier)) {
            alias = qualifier;
        }

        BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className,
                new String[] { alias });
        BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
    }
CH4:D
@chad_d_stud_twitter
May 09 2018 11:51
@marcosbarbero the funny thing is if you use the code in the example (assuming your build.gradle includes the necessary deps) that should be pretty much it :)
i just changed the FeignClient’s name to my own
D D
@dosdebug
May 09 2018 11:52
No, what I am trying to tell you is, it registers only if there are basePackages property set
So, can you show, how have you enabled feign client? Specifically, can you show how did you add @EnableFeignClients?
CH4:D
@chad_d_stud_twitter
May 09 2018 11:55
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableCircuitBreaker
public class TestApplication {

}
@RestController
@RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) //, consumes=MediaType.APPLICATION_JSON_UTF8_VALUE)
@Slf4j
@RefreshScope
public class TestRestController {
       @Autowired
    protected MyFeignClient myFeignClient;

       @GetMapping("/hystrixtest")
    public EndpointResult<Wallet> transactEndpoint() {

        return myFeignClient.test(“test");
    }
}
myfeign is the earlier code i sent
D D
@dosdebug
May 09 2018 11:59
Okay, so can you add @EnableFeignClients(basePackages={"yourpackagewhereyourclientis"}
CH4:D
@chad_d_stud_twitter
May 09 2018 12:07
Oh. I'll try that after dinner.
I didn't need. That when I tried using Hystrix in Hystrixtest
The fallback method words from there
S
The fallback method works from here.
*there. Sorry on my phone
Hystrix by itself works on my end too. Just not with feign and Hystrix
D D
@dosdebug
May 09 2018 12:14
Okay
D D
@dosdebug
May 09 2018 12:30
I want to understand something related to FeignClientsRegistrar, all beans definitions are held in BeanDefinitionHolder, so how calling myFeignClient.myMethod() invokes the URL? Where can I see in code to understand in detail?
CH4:D
@chad_d_stud_twitter
May 09 2018 13:06
@dosdebug still the same error:
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackageClasses = {MyFeignClient.class})
@EnableCircuitBreaker
public class TestApplication {
}
D D
@dosdebug
May 09 2018 13:07
Yep, I see because even if basePackages is not provided, it defaults to the package where this annotation is applied.
I am myself debugging this through org.springframework.cloud.netflix.feign package and that’s why I asked above question :) Hope someone replies :(
CH4:D
@chad_d_stud_twitter
May 09 2018 13:13
@FeignClient(name = "myfeign", fallback = FeignClientCallback.class)
public interface FeignClient {    
    Object test(@RequestParam("param1") String param1);

    static class FeignClientCallback implements FeignClient {
        @Override
        public Object test(String param1) {
            return "I failed";
        }        
    }
}
on the other hand, this works:
@GetMapping("/hystrixtest")
    @HystrixCommand(fallbackMethod = "iHazFailed")
    public Object transactEndpoint(@RequestParam("test") String test) {
        return feignClient.test(test);
    }

    public String iHazFailed(String test) {
        return "{ \"message\": \"I haz failed thee.\"}";
    }
but that’s just basic hystrix
i also discovered another issue with that chunk of code but totally unrelated to the issue i’ve raised
turning off the remote service triggers the fallback method but once it’s up, calling it repeatedly by hitting the refresh, the fallback is called every other time
D D
@dosdebug
May 09 2018 13:18
@chad_d_stud_twitter You mean when you turn service back on, it still falls back?
CH4:D
@chad_d_stud_twitter
May 09 2018 13:18
yes, 50/50 of the time
D D
@dosdebug
May 09 2018 13:18
I think it takes time for a service to register itself with registry service
CH4:D
@chad_d_stud_twitter
May 09 2018 13:19
i hit refresh once, it’s fine. i hit refresh again it calls fallback
D D
@dosdebug
May 09 2018 13:19
Uhh...
CH4:D
@chad_d_stud_twitter
May 09 2018 13:19
then i hit again it’s fine
it’s not exactly 50/50 it just calls it at some random moment. intermittent so to speak
weird stuff
D D
@dosdebug
May 09 2018 13:20
Yeah, can someone from dev team please help and explain this? @ryanjbaxter @dsyer ?
CH4:D
@chad_d_stud_twitter
May 09 2018 13:21
maybe you can try setting that up on your end to see if it happens to you?
that’s pretty much the only hystrix method i have
i just added it in as a proof of concept to my team
ulmermark
@ulmermark
May 09 2018 21:28
Have a question around health.config.enabled=true and the application uses Discovery to discover the config server on startup. Noticing that the application health check will go from UP to DOWN if the Config Server is recycled. It appears to "remember" the original Config Server that was discovered on Startup of the application and does not use the "NEW" instance of Config Server during Health checks...