Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
tool
/
xxl-job
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b96d2296
authored
May 24, 2025
by
xuxueli
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(AI执行器): 优化 DifyWorkflowJobHandler 配置方式
1 parent
8787f70c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
29 deletions
README.md
doc/XXL-JOB官方文档.md
doc/db/tables_xxl_job.sql
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/java/com/xxl/job/executor/controller/IndexController.java
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/java/com/xxl/job/executor/jobhandler/AIXxlJob.java
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/resources/application.properties
README.md
View file @
b96d229
...
...
@@ -843,6 +843,8 @@ XXL-JOB 是一个开源且免费项目,其正在进行的开发完全得益于
-
689、广东西欧克实业有限公司
-
690、唱吧麦颂KTV
-
691、联通云
-
692、北京爱话本科技有限公司
-
693、北京起创科技有限公司
-
……
> 更多接入的公司,欢迎在 [登记地址](https://github.com/xuxueli/xxl-job/issues/1 ) 登记,登记仅仅为了产品推广。
...
...
doc/XXL-JOB官方文档.md
View file @
b96d229
...
...
@@ -786,6 +786,8 @@ XXL-JOB譏ッ荳荳ェ蛻クシ丈ササ蜉。隹コヲ蟷ウ蜿ー悟譬ク蠢ョセ隶。逶ョ譬弍蠑蜿題ソ
- 689、广东西欧克实业有限公司
- 690、唱吧麦颂KTV
- 691、联通云
- 692、北京爱话本科技有限公司
- 693、北京起创科技有限公司
- ……
> 更多接入的公司,欢迎在 [登记地址](https://github.com/xuxueli/xxl-job/issues/1 ) 登记,登记仅仅为了产品推广。
...
...
@@ -1207,13 +1209,15 @@ public void demoJobHandler() throws Exception {
"prompt": "{模型prompt,可选信息}"
}
```
-
b、difyWorkflowJobHandler:DifyWorkflow 任务,支持自定义inputs、user等输入信息,示例参数如下;
-
b、difyWorkflowJobHandler:DifyWorkflow 任务,支持自定义inputs、user、b
aseUrl、apiKey 等输
入信息,示例参数如下;
```
{
"inputs":{ // inputs 为dify工作流任务参数;参数不固定,结合各自 workflow 自行定义。
"input":"{用户输入信息}" // 该参数为示例变量,需要 workflow 的“开始”节点 自定义参数 “input”,可自行调整或删除。
"inputs":{
// inputs 为dify工作流任务参数;参数不固定,结合各自 workflow 自行定义。
"input":"{用户输入信息}"
// 该
参数为示例变量,需要 workflow 的“开始”节点 自定义参数 “input”,可自行调整或删除。
},
"user": "{用户标识,选填}"
"user": "xxl-job", // 用户标识,选填
"baseUrl": "http://localhost/v1", // Dify应用的 访问API 地址,需要从 Dify 系统获取;
"apiKey": "xxx" // Dify应用的 API-Key,需要从 Dify 系统获取;
}
```
...
...
@@ -2521,7 +2525,7 @@ public void execute() {
```
-
2、【新增】新增多个 Bean模式 AI任务Handler,如 ollamaJobHandler、difyWorkflowJobHandler 等,支持快速集成开发AI任务。任务配置可参考
[
AI执行器
](
https://www.xuxueli.com/xxl-job/#原生内置Bean模式任务(AI执行器)
)
-
a、ollamaJobHandler: OllamaChat任务,支持自定义prompt、input等输入信息。
-
b、difyWorkflowJobHandler:DifyWorkflow 任务,支持自定义inputs、user等输入信息。
-
b、difyWorkflowJobHandler:DifyWorkflow 任务,支持自定义inputs、user、b
aseUrl、apiKey等输
入信息。
-
3、【修复】合并PR-3708、PR-3704,解决固定速度调度模式下,下次计算执行时间小概率(间隔超长时)不准问题。
-
4、【修复】任务操作逻辑优化,修复边界情况下逻辑中断问题 (ISSUE-2081)。
-
5、【修复】调度中心Cron前端组件优化,解决week配置与后端兼容性问题 (ISSUE-2220)。
...
...
@@ -2533,8 +2537,9 @@ public void execute() {
### 7.39 版本 v3.1.1 Release Notes[规划中]
-
1、
[
规划中
]
登陆态Token生成逻辑优化,混淆登陆时间属性,降低token泄漏风险;
-
2、
[
规划中
]
组件扫描改为BeanPostProcessor方式,避免小概率情况下提前初始化;底层组件移除单例写法,汇总factory统一管理;
-
1、【调整】AI执行器任务(difyWorkflowJobHandler)优化:将 “baseUrl、apiKey” 等Dify配置信息,从执行器侧文件类配置调整至调度中心“任务参数”动态配置,提升多Dify应用集成效率。
-
2、
[
规划中
]
登陆态Token生成逻辑优化,混淆登陆时间属性,降低token泄漏风险;
-
3、
[
规划中
]
组件扫描改为BeanPostProcessor方式,避免小概率情况下提前初始化;底层组件移除单例写法,汇总factory统一管理;
### TODO LIST
-
1、调度隔离:调度中心针对不同执行器,各自维护不同的调度和远程触发组件。
...
...
doc/db/tables_xxl_job.sql
View file @
b96d229
...
...
@@ -157,7 +157,9 @@ VALUES (1, 1, '示例任务01', now(), now(), 'XXL', '', 'CRON', '0 0 0 * * ? *'
"inputs":{
"input":"查询班级各学科前三名"
},
"user": "xxl-job"
"user": "xxl-job",
"baseUrl": "http://localhost/v1",
"apiKey": "app-OUVgNUOQRIMokfmuJvBJoUTN"
}'
,
'SERIAL_EXECUTION'
,
0
,
0
,
'BEAN'
,
''
,
'GLUE代码初始化'
,
now
(),
''
)
;
...
...
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/java/com/xxl/job/executor/controller/IndexController.java
View file @
b96d229
...
...
@@ -79,10 +79,9 @@ public class IndexController {
// --------------------------------- dify workflow ---------------------------------
@Value
(
"${dify.api-key}"
)
private
String
apiKey
;
@Value
(
"${dify.base-url}"
)
private
String
baseUrl
;
// dify config sample
private
final
String
apiKey
=
"http://localhost/v1"
;
private
final
String
baseUrl
=
"app-OUVgNUOQRIMokfmuJvBJoUTN"
;
@GetMapping
(
"/dify/simple"
)
@ResponseBody
...
...
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/java/com/xxl/job/executor/jobhandler/AIXxlJob.java
View file @
b96d229
...
...
@@ -10,7 +10,6 @@ import io.github.imfangs.dify.client.model.workflow.WorkflowRunRequest;
import
io.github.imfangs.dify.client.model.workflow.WorkflowRunResponse
;
import
jakarta.annotation.Resource
;
import
org.springframework.ai.chat.client.ChatClient
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
...
...
@@ -103,12 +102,6 @@ public class AIXxlJob {
}
@Value
(
"${dify.api-key}"
)
private
String
apiKey
;
@Value
(
"${dify.base-url}"
)
private
String
baseUrl
;
/**
* 2、dify Workflow任务
*
...
...
@@ -143,6 +136,11 @@ public class AIXxlJob {
if
(
difyParam
.
getUser
()
==
null
)
{
difyParam
.
setUser
(
"xxl-job"
);
}
if
(
difyParam
.
getBaseUrl
()==
null
||
difyParam
.
getApiKey
()==
null
)
{
XxlJobHelper
.
log
(
"baseUrl or apiKey invalid."
);
XxlJobHelper
.
handleFail
();
return
;
}
}
catch
(
Exception
e
)
{
XxlJobHelper
.
log
(
new
RuntimeException
(
"DifyParam parse error"
,
e
));
XxlJobHelper
.
handleFail
();
...
...
@@ -161,7 +159,7 @@ public class AIXxlJob {
.
build
();
// dify invoke
DifyWorkflowClient
workflowClient
=
DifyClientFactory
.
createWorkflowClient
(
baseUrl
,
apiKey
);
DifyWorkflowClient
workflowClient
=
DifyClientFactory
.
createWorkflowClient
(
difyParam
.
getBaseUrl
(),
difyParam
.
getApiKey
()
);
WorkflowRunResponse
response
=
workflowClient
.
runWorkflow
(
request
);
// response
...
...
@@ -171,15 +169,25 @@ public class AIXxlJob {
private
static
class
DifyParam
{
/**
*
输入参数,允许传入
App 定义的各变量值
*
dify input, 允许传入 Dify
App 定义的各变量值
*/
private
Map
<
String
,
Object
>
inputs
;
/**
*
用户标识
*
dify user
*/
private
String
user
;
/**
* dify baseUrl
*/
private
String
baseUrl
;
/**
* dify apiKey
*/
private
String
apiKey
;
public
Map
<
String
,
Object
>
getInputs
()
{
return
inputs
;
}
...
...
@@ -196,7 +204,22 @@ public class AIXxlJob {
this
.
user
=
user
;
}
}
public
String
getBaseUrl
()
{
return
baseUrl
;
}
public
void
setBaseUrl
(
String
baseUrl
)
{
this
.
baseUrl
=
baseUrl
;
}
public
String
getApiKey
()
{
return
apiKey
;
}
public
void
setApiKey
(
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
}
}
xxl-job-executor-samples/xxl-job-executor-sample-springboot-ai/src/main/resources/application.properties
View file @
b96d229
...
...
@@ -37,9 +37,3 @@ spring.ai.ollama.chat.enabled=true
### chat model,must install it locally through ollama
spring.ai.ollama.chat.options.model
=
qwen2.5:1.5b
spring.ai.ollama.chat.options.temperature
=
0.8
### dify url
dify.base-
url
=
http://localhost/v1
### dify api-key
dify.api-
key
=
app-OUVgNUOQRIMokfmuJvBJoUTN
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment