bladex-xxl-job使用
1.整合bladex,配置docker,install 后编辑 DockerFile .. build.. push到HaBor,并且安装jdk nacos sentinel redis minio等等组件,
这里只展示dockercompose yml内容
version: '3.8'
networks:
one-full-network:
name: one-full-network
external: true
services:
blade-admin:
image: 192.168.12.52:81/blade-service/blade-admin:${BLADEX_VERSION}
container_name: blade-admin
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=7002
ports:
- "7002:7002"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-auth:
image: 192.168.12.52:81/blade-service/blade-auth:${BLADEX_VERSION}
container_name: blade-auth
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8100
ports:
- "8100:8100"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-desk:
image: 192.168.12.52:81/blade-service/blade-desk:${BLADEX_VERSION}
container_name: blade-desk
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8105
ports:
- "8105:8105"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-gateway:
image: 192.168.12.52:81/blade-service/blade-gateway:${BLADEX_VERSION}
container_name: blade-gateway
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=9001
ports:
- "9001:9001"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-log:
image: 192.168.12.52:81/blade-service/blade-log:${BLADEX_VERSION}
container_name: blade-log
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8103
ports:
- "8103:8103"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-report:
image: 192.168.12.52:81/blade-service/blade-report:${BLADEX_VERSION}
container_name: blade-report
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8108
ports:
- "8108:8108"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-resource:
image: 192.168.12.52:81/blade-service/blade-resource:${BLADEX_VERSION}
container_name: blade-resource
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8010
ports:
- "8010:8010"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-swagger:
image: 192.168.12.52:81/blade-service/blade-swagger:${BLADEX_VERSION}
container_name: blade-swagger
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=18000
ports:
- "18000:18000"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-system:
image: 192.168.12.52:81/blade-service/blade-system:${BLADEX_VERSION}
container_name: blade-system
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8106
ports:
- "8106:8106"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-user:
image: 192.168.12.52:81/blade-service/blade-user:${BLADEX_VERSION}
container_name: blade-user
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8102
ports:
- "8102:8102"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-xxljob-admin:
image: 192.168.12.52:81/blade-service/blade-xxljob-admin:${BLADEX_VERSION}
container_name: blade-xxljob-admin
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=7009
ports:
- "7009:7009"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-develop:
image: 192.168.12.52:81/blade-service/blade-develop:${BLADEX_VERSION}
container_name: blade-develop
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=7007
ports:
- "7007:7007"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
blade-flow:
image: 192.168.12.52:81/blade-service/blade-flow:${BLADEX_VERSION}
container_name: blade-flow
restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "300m"
environment:
- ACTIVE=${ACTIVE}
- NACOS_ADDR=${NACOS_ADDR}
- NACOS_NAMESPACE=${NACOS_NAMESPACE}
- spring.cloud.nacos.discovery.ip=${NACOS_DISCOVERY_IP}
- spring.cloud.nacos.discovery.port=8008
ports:
- "8008:8008"
volumes:
- ./logs:/opt/logs
networks:
- one-full-network
2.程序中引用xxljobcore包
3.由于程序已经把配置文件上传到了nacos,所以查看下nacos中的xxljob配置
这里注意,bladex common中指向读取配置的位置,并且读取配置文件名 = 服务名 + “_dev”
4.登录http://192.168.11.11:7009/xxl-job-admin/jobinfo 配置执行器 trafficActuator和上一步的nacos配置执行器名称一致
测试当你的项目启动并注册到nacos时,“OnLine”机器地址就会显示ip地址,谁启动显示谁的ip,并且可叠加。
5.在“任务管理”创建job,注意JobHandler与代码中的注解名称对应,路由策略默认为"第一个" ,按需要修改策略。
6.操作可查看执行日志