欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php項目接入xxl-job調(diào)度系統(tǒng)的示例詳解

 更新時間:2021年12月15日 12:10:21   作者:木魚大叔  
這篇文章主要介紹了php項目接入xxl-job調(diào)度系統(tǒng)的示例代碼,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1.?部署xxl-job調(diào)度中心

此處略,請自行百度。下面重點介紹如何將php項目接入xxl-job調(diào)度。

2. 整合xxl-job調(diào)度系統(tǒng)

核心是使用xxl-job的GLUE運行模式,通過一段php代碼片段,調(diào)用遠(yuǎn)程的http資源。

2.1 創(chuàng)建執(zhí)行器項目

參考執(zhí)行器示例項目, xxl-job-executor-samples/xxl-job-executor-sample-springboot,修改下其中的 application.properties 文件,內(nèi)容如下:

# 執(zhí)行器項目使用的端口號
server.port=8585
# no web
#spring.main.web-environment=false
 
# log config
logging.config=classpath:logback.xml
 
### 調(diào)度中心地址
xxl.job.admin.addresses=http://127.0.0.1:8081/job-admin
 
### xxl-job, access token
xxl.job.accessToken=
 
### xxl-job executor appname
xxl.job.executor.appname=xxl-job-executor-base
### xxl-job executor registry-address: default use address to registry , otherwise use ip:port if address is null
xxl.job.executor.address=
### xxl-job executor server-info
xxl.job.executor.ip=127.0.0.1
xxl.job.executor.port=9999
### xxl-job executor log-path
xxl.job.executor.logpath=xxl-job-log
### xxl-job executor log-retention-days
xxl.job.executor.logretentiondays=30

2.2 新增執(zhí)行器

在調(diào)度中心的管理界面,新增一個執(zhí)行器,執(zhí)行器的相關(guān)信息必須與【2.1】步驟中的配置保持一致,如下:

?注意:此處的機(jī)器地址,在新版中必須帶上協(xié)議名稱,如:http。

?2.3 部署執(zhí)行器項目

將編譯好的 xxl-job-executor-sample-springboot-2.2.1-SNAPSHOT.jar 包,復(fù)制到php項目所在的機(jī)器上,并啟動。啟動命令為:

java -jar -Dfile.encoding=utf-8 "xxl-job-executor-sample-springboot-2.2.1-SNAPSHOT.jar"

2.4 新增GLUE模式任務(wù)

?執(zhí)行器選擇【2.2】步驟中新建的執(zhí)行器即可,運行模式選擇【GLUE(PHP)】。

2.5 編寫php代碼片段

在任務(wù)列表中,找到之前新建的GLUE任務(wù),然后在對應(yīng)的操作欄中,選擇【GLUE IDE】菜單,進(jìn)入xxl-job內(nèi)置的web編輯器,即可編寫與業(yè)務(wù)相關(guān)的php代碼。

?示例內(nèi)容如下:

<?php
    $url = 'https://www.baidu.com/';
	$result = file_get_contents($url);
	var_dump($result);
	exit(0);
?>

?注意:

① 腳本任務(wù)通過 Exit Code 判斷任務(wù)執(zhí)行結(jié)果,0 成功,-1(非0狀態(tài)碼)失敗。

② 調(diào)度過程中,將會在 gluesource 目錄(位于日志根目錄下)下,生成一個臨時的php文件,文件內(nèi)容即為步驟【2.5】中編寫的代碼片段。

到此這篇關(guān)于php項目接入xxl-job調(diào)度系統(tǒng)的文章就介紹到這了,更多相關(guān)php項目接入xxl-job內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論