xxl-job 실행기 시작 오류 ERROR c.x.job.core.executor.XxlJobExecutor - null

9514 단어 난치병
환경 xxl-job 2.2.0,springboot 버전 2.3.1.RELEASE, 스케줄러가 정상적인 실행기를 시작하면destroy () 방법에서 오류를 보고합니다.registryThread 빈 바늘
18:20:34.102 logback [main] INFO  c.e.demo.ChahuashiServiceApplication - Started ChahuashiServiceApplication in 0.954 seconds (JVM running for 1.657)
18:20:34.106 logback [SpringContextShutdownHook] INFO  o.s.s.c.ThreadPoolTaskExecutor - Shutting down ExecutorService 'applicationTaskExecutor'
18:20:34.110 logback [SpringContextShutdownHook] ERROR c.x.job.core.executor.XxlJobExecutor - null
java.lang.NullPointerException: null
	at com.xxl.job.core.thread.ExecutorRegistryThread.toStop(ExecutorRegistryThread.java:117)
	at com.xxl.job.core.server.EmbedServer.stopRegistry(EmbedServer.java:262)
	at com.xxl.job.core.server.EmbedServer.stop(EmbedServer.java:124)
	at com.xxl.job.core.executor.XxlJobExecutor.stopEmbedServer(XxlJobExecutor.java:158)
	at com.xxl.job.core.executor.XxlJobExecutor.destroy(XxlJobExecutor.java:85)
	at com.xxl.job.core.executor.impl.XxlJobSpringExecutor.destroy(XxlJobSpringExecutor.java:57)
	at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:258)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:579)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:551)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1089)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1082)
	at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1061)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1030)
	at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:949)
18:20:34.110 logback [xxl-job, executor JobLogFileCleanThread] INFO  c.x.j.c.thread.JobLogFileCleanThread - >>>>>>>>>>> xxl-job, executor JobLogFileCleanThread thread destory.
18:20:34.110 logback [xxl-job, executor TriggerCallbackThread] INFO  c.x.j.c.thread.TriggerCallbackThread - >>>>>>>>>>> xxl-job, executor callback thread destory.
18:20:34.110 logback [Thread-80] INFO  c.x.j.c.thread.TriggerCallbackThread - >>>>>>>>>>> xxl-job, executor retry callback thread destory.

Process finished with exit code 0


인터럽트 디버깅을 반복하면 debug를 발견할 때 start () 방법에 잠시 머무르면destroy () 시공 바늘을 실행하는 것을 피할 수 있기 때문에 가장 간단한 해결 방법이 있습니다.핵심 모듈을 수정하는com.xxl.job.core.executor.impl.XxlJobSpringExecutor, start() 메서드 후 지연 시간 추가
	// start
    @Override
    public void afterSingletonsInstantiated() {

        // init JobHandler Repository
        /*initJobHandlerRepository(applicationContext);*/

        // init JobHandler Repository (for method)
        initJobHandlerMethodRepository(applicationContext);

        // refresh GlueFactory
        GlueFactory.refreshInstance(1);

        // super start
        try {
            super.start();
            // 1s, destroy() 
            Thread.sleep(1000);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    // destroy
    @Override
    public void destroy() {
        super.destroy();
    }

다음은 이전 Xxl Job Spring Executor 등록 Bean에 serAddress를 추가하지 않았습니다. 기본값은 비어 있는 것으로 알고 xxl Job Spring Executor를 추가했습니다.setAddress(address); 다시는 상술한 잘못을 만나지 못했으니, 구체적으로 실현된 후에 다시 보자, 우선 이 구덩이를 메워라
 @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        logger.info(">>>>>>>>>>> xxl-job config init.");
        // xxlJobSpringExecutor 
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
        xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
        xxlJobSpringExecutor.setAppname(appname);
        xxlJobSpringExecutor.setAddress(address);
        xxlJobSpringExecutor.setIp(ip);
        xxlJobSpringExecutor.setPort(port);
        xxlJobSpringExecutor.setAccessToken(accessToken);
        xxlJobSpringExecutor.setLogPath(logPath);
        xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
        return xxlJobSpringExecutor;
    }

좋은 웹페이지 즐겨찾기