-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
自定义 RejectedExecutionHandler 启动问题 #432
Comments
没有配置spi? |
感谢您的回复,我没有理解你的意思? spi 配置是做什么配置呢? 我没有使用配置中心的动态线程池,而是使用框架案例中@bean方式生成的线程池,
然后该配置与 dtpLifecycle 类自动配置相关有冲突报错截取如下 org.springframework.context.ApplicationContextException: Failed to start bean 'dtpLifecycle'; nested exception is org.dromara.dynamictp.common.ex.DtpException: Cannot find specified rejectedHandler CustomRejectPolicy
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at com.pec.retail.mdc.MdcServiceApplication.main(MdcServiceApplication.java:23)
Caused by: org.dromara.dynamictp.common.ex.DtpException: Cannot find specified rejectedHandler CustomRejectPolicy 从报错上看应该是框架没法找到我自定义的拒绝策略CustomRejectPolicy ,上文有述说过不在赘述. |
https://dynamictp.cn/guide/notice/custom.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E9%80%9A%E7%9F%A5%E6%B8%A0%E9%81%93 可以参考这个,resources/META-INF/services 下配置 java spi 实现 |
版本
sprinboot 2.3.4.RELEASE
jdk8
问题
如果我使用自定义的拒绝策略,我将无法正常启动
在 使用懒加载获取该自定义拒绝策略org.dromara.dynamictp.common.util.ExtensionServiceLoader.load(Class clazz)方法中
ServiceLoader.load(clazz); 将无法获取到我自定义的 CustomRejectPolicy ,我看到 ThreadPoolBuilder.newBuilder() 方法提供了rejectedExecutionHandler(RejectedExecutionHandler handler) 的方法.我改怎么做呢? CustomRejectPolicy 已经交由 spring 使用 @resource 注解获取
The text was updated successfully, but these errors were encountered: