From df3e1d8e180638b3f63798e8a5ee85b94f32c5c4 Mon Sep 17 00:00:00 2001 From: abellwu Date: Thu, 25 May 2023 19:38:08 +0800 Subject: [PATCH 1/2] fix tct demo getBean use invalid name --- .../com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java index cec97cc..ae9a422 100644 --- a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java +++ b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java @@ -27,7 +27,6 @@ public class SpringExecuteTaskFactory implements ExecutableTaskFactory, Applicat public ExecutableTask newExecutableTask(ExecutableTaskData executableTaskData) throws InstancingException { try { ExecutableTask executableTask = (ExecutableTask)applicationContext.getBean(Class.forName(executableTaskData.getTaskContent())); - applicationContext.getBean(executableTaskData.getTaskContent(),ExecutableTask.class); LOG.info("generate executableTask bean SpringExecutableTaskFactory. taskName: {}", executableTaskData.getTaskContent()); return executableTask; } catch (Throwable t) { From 8380290c10ef9212223231f1f1abae896257464e Mon Sep 17 00:00:00 2001 From: abellwu Date: Thu, 25 May 2023 20:06:45 +0800 Subject: [PATCH 2/2] add more log --- .../task/factory/SpringExecuteTaskFactory.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java index ae9a422..1127bf7 100644 --- a/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java +++ b/task-schedule-demo/src/main/java/com/tencent/cloud/task/factory/SpringExecuteTaskFactory.java @@ -1,10 +1,7 @@ package com.tencent.cloud.task.factory; -import com.tencent.cloud.task.sdk.client.DefaultTaskFactory; -import com.tencent.cloud.task.sdk.client.exception.InstancingException; -import com.tencent.cloud.task.sdk.client.model.ExecutableTaskData; -import com.tencent.cloud.task.sdk.client.spi.ExecutableTask; -import com.tencent.cloud.task.sdk.client.spi.ExecutableTaskFactory; +import java.lang.invoke.MethodHandles; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -12,7 +9,11 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; -import java.lang.invoke.MethodHandles; +import com.tencent.cloud.task.sdk.client.DefaultTaskFactory; +import com.tencent.cloud.task.sdk.client.exception.InstancingException; +import com.tencent.cloud.task.sdk.client.model.ExecutableTaskData; +import com.tencent.cloud.task.sdk.client.spi.ExecutableTask; +import com.tencent.cloud.task.sdk.client.spi.ExecutableTaskFactory; @Component public class SpringExecuteTaskFactory implements ExecutableTaskFactory, ApplicationContextAware { @@ -26,10 +27,11 @@ public class SpringExecuteTaskFactory implements ExecutableTaskFactory, Applicat @Override public ExecutableTask newExecutableTask(ExecutableTaskData executableTaskData) throws InstancingException { try { - ExecutableTask executableTask = (ExecutableTask)applicationContext.getBean(Class.forName(executableTaskData.getTaskContent())); + ExecutableTask executableTask = (ExecutableTask) applicationContext.getBean(Class.forName(executableTaskData.getTaskContent())); LOG.info("generate executableTask bean SpringExecutableTaskFactory. taskName: {}", executableTaskData.getTaskContent()); return executableTask; } catch (Throwable t) { + LOG.warn("executableTask bean not found, try default factory. taskName: {}", executableTaskData.getTaskContent()); return defaultFactory.newExecutableTask(executableTaskData); } }