Spring-cloud-netflix: Allow init params to be set on ProxyStreamServlet

Created on 26 Sep 2017  路  8Comments  路  Source: spring-cloud/spring-cloud-netflix

I'm facing this issues in spring-cloud-netflix and trying to address the same. Since I cannot disable stuck-thread max-time for my managed-servers, I'm trying to assign a work-manager with stuck-thread max-time disabled to HystrixMetricsStreamServlet. This is the approach I though of.

  • Introduce a new auto-configuration (since I have over 20 microservices) which sets hystrix.stream.endpoint.enabled to false. So that HystrixStreamEndpoint will not be constructed.
  • Then in my auto-configuration, create a ServletWrappingEndpoint bean wrapping the HystrixMetricsStreamServlet.
  • Now for this servlet I must pass the name of the work-manager as an init-param.
  1. Do you see a better approach to solve this issue?
  2. I would suggest the ServletWrappingEndpoint class to accept ServletWrappingController in it's constructor since ServletWrappingEndpoint does not allow setting init params. (Calling the getController() getter would cause _invoking overridable methods from constructors_).
question

All 8 comments

That class is going to go away in 2.0.0. I'd suggest you just copy it and make whatever changes you need. I doesn't do much.

Thanks @spencergibb. I found the same issue with ProxyStreamServlet as well and the workaround is not straight-forward since ProxyStreamServlet bean construction is not conditional on any property. The workaround is to sub-class HystrixDashboardConfiguration and introduce a new _Enable_ annotation. i.e.

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Import(HystrixWebLogicDashboardConfiguration.class)
public @interface EnableWebLogicHystrixDashboard {

}
@Configuration
public class HystrixWebLogicDashboardConfiguration extends HystrixDashboardConfiguration {

    @Autowired
    private HystrixDashboardProperties dashboardProperties;

    @Bean
    public ServletRegistrationBean proxyStreamServlet() {
        ProxyStreamServlet proxyStreamServlet = new ProxyStreamServlet();
        proxyStreamServlet.setEnableIgnoreConnectionCloseHeader(dashboardProperties.isEnableIgnoreConnectionCloseHeader());
        ServletRegistrationBean bean = new ServletRegistrationBean(proxyStreamServlet, "/proxy.stream");
        bean.addInitParameter("wl-dispatch-policy", "WorkManager-Hystrix");
        return bean;    
    }
}


However, in order to avoid such workarounds for WebLogic users, it would be nicer to have the following configurations

  1. The registration of ProxyStreamServlet to accept some init parameters from properties.
hystrix.proxy-servlet.init.parameter.name=
hystrix.proxy-servlet.init.parameter.value=

May be an array of such params...

  1. Register the HystrixMetricsStreamServlet through ServletRegistrationBean, rather than exposing it as an Endpoint. Also to accept some init parameters from properties - - same as above.

HystrixDashboardProperties could be enhanced to have a map of init parameters. Hystrix has already been changed to accept init params in 2.0.x see 61513287ce078f7ef57ca480b8a75ae0ce27b2bb

That's great! Would like to file a pull request for HystrixDashboardProperties .

@fahimfarookme absolutely!

@spencergibb Hope the target branch should be 2.0.x?

Can be master if done promptly.

For WebLogic users, until spring-cloud-netflix 2.0.x is released - here's the workaround as a library which was discussed above.

Was this page helpful?
0 / 5 - 0 ratings