You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/09/01 02:18:53 UTC

[GitHub] [dubbo] cl900503 commented on issue #10517: 通过@DubboReference方式注入服务,如何提前完成初始化工作,避免服务接口首次调用出现耗时较久的问题。

cl900503 commented on issue #10517:
URL: https://github.com/apache/dubbo/issues/10517#issuecomment-1233655944

   > 加一个在接受请求进来前的时间点调 rpc 接口,数据自己造一下
   > 
   > 可以使用回声测试 https://dubbo.apache.org/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/echo-service/
   
   接口调用前,先进行了下面的动作:
   ``` java
   	@Bean
   	@DubboReference(interfaceClass = IdGeneratorService.Iface.class, version = "1.0", timeout = 5000, init = true, lazy = false)
   	public ReferenceBean<IdGeneratorService.Iface> idGeneratorService() {
   		return new ReferenceBean<IdGeneratorService.Iface>();
   	}
   
   	@Bean
   	public IdGeneratorService.Iface initIdGeneratorService(ReferenceBean<IdGeneratorService.Iface> idGeneratorService) {
   		IdGeneratorService.Iface initedId = idGeneratorService.getObject();	
   		idGeneratorService.getReferenceConfig().setCheck(false);
   		idGeneratorService.getReferenceConfig().get();		
   		return initedId;
   	}
   ```
   后面通过下面方式注入
   ``` java
   	@Autowired
   	private IdGeneratorService.Iface initIdGeneratorService;
   ```
   
   首次进行接口调用的时候,耗时有大幅缩减,但是相较于后续的调用,还是大概多耗时100ms,请指点下,这部分差距在进行什么动作,如何预热?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org