Skip to content

Commit

Permalink
20241125
Browse files Browse the repository at this point in the history
  • Loading branch information
ldcsaa committed Nov 25, 2024
1 parent b6c2f63 commit a34c516
Show file tree
Hide file tree
Showing 235 changed files with 2,030 additions and 360 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- 消息队列:Kafka(支持可靠消息)
- MQTT发布订阅:Eclipse PAHO mqttv5
- 分布式Job:xxl-job
- 分布式Job:snail-job
- 轻量级Job:Redisson + Spring Scheduled
- 分布式事务:Seata
- 全局ID:Leaf(支持 Snowflake ID 和 Segment ID)
Expand Down Expand Up @@ -56,6 +57,7 @@
- **[hp-soa-starter-mqtt](hp-soa-starter/hp-soa-starter-mqtt)** MQTT启动器,开启MQTT发布订阅功能,全面支持mqttv5协议
- **[hp-soa-starter-job-exclusive](hp-soa-starter/hp-soa-starter-job-exclusive)** 轻量级Job启动器,开启轻量级排他Job功能,提供Job执行日志关联和调用链跟踪能力
- **[hp-soa-starter-job-xxljob](hp-soa-starter/hp-soa-starter-job-xxljob)** Xxl-Job启动器,开启 Xxl-Job 功能,结合 xxl-job-admin 提供分布式Job能力
- **[hp-soa-starter-job-snailjob](hp-soa-starter/hp-soa-starter-job-snailjob)** Snail-Job启动器,开启 Snail-Job 功能,结合 snail-job-server 提供分布式Job能力
- **[hp-soa-starter-leaf](hp-soa-starter/hp-soa-starter-leaf)** Leaf全局ID启动器,开启Leaf全局ID功能,支持通过Snowflake算法和Segment算法生成全局ID
- **[hp-soa-starter-seata](hp-soa-starter/hp-soa-starter-seata)** Seata启动器,开启Seata分布式事务功能,结合 Seata TC 提供分布式事务能力
- **[hp-soa-starter-sentinel](hp-soa-starter/hp-soa-starter-sentinel)** Sentinel启动器,开启Sentinel流量控制功能,结合 Sentinel Dashboard 和 Nacos 提供流量控制和流控规则持久化能力
Expand Down
4 changes: 4 additions & 0 deletions hp-demo/hp-demo-job/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<groupId>io.github.hpsocket</groupId>
<artifactId>hp-soa-starter-job-xxljob</artifactId>
</dependency>
<dependency>
<groupId>io.github.hpsocket</groupId>
<artifactId>hp-soa-starter-job-snailjob</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ public class ExclusiveJobHandler
int i = 0;

//@Scheduled(cron = "*/5 * * * * ?")
@ExclusiveJob(jobName = "job1", cron = "*/5 * * * * ?")
@ExclusiveJob(jobName = "job1", cron = "*/5 * * * * ?", writeExecLog = true)
public void job1()
{
log.info("traceId: {}", WebServerHelper.getTraceId());

if((++i) % 5 == 0)
throw new RuntimeException("test thow exceptions");

log.info("traceId: {}", WebServerHelper.getTraceId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.hpsocket.demo.job.handler;

import org.springframework.stereotype.Component;

import io.github.hpsocket.soa.framework.web.support.WebServerHelper;

import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
@JobExecutor(name = "classAnnotationJob", method = "doClassAnnotationJob")
public class SnailAnnotationJobHandler
{
private int i;

public ExecuteResult doClassAnnotationJob(JobArgs jobArgs)
{
log.info("traceId: {}", WebServerHelper.getTraceId());

if((++i) % 5 == 0)
throw new RuntimeException("test thow exceptions");

return ExecuteResult.success(jobArgs.getTaskBatchId());
}

@JobExecutor(name = "methodAnnotationJob")
public ExecuteResult doMethodAnnotationJob(JobArgs jobArgs)
{
log.info("traceId: {}", WebServerHelper.getTraceId());

if((++i) % 5 == 0)
throw new RuntimeException("test thow exceptions");

return ExecuteResult.success(jobArgs.getTaskBatchId());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.github.hpsocket.demo.job.handler;

import org.springframework.stereotype.Component;

import io.github.hpsocket.soa.framework.web.support.WebServerHelper;
import io.github.hpsocket.soa.starter.job.snailjob.executor.AbstractMdcJobExecutor;

import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
public class SnailInheritJobHandler extends AbstractMdcJobExecutor
{
private int i;

@Override
protected ExecuteResult doJobExecuteEx(JobArgs jobArgs)
{
log.info("traceId: {}", WebServerHelper.getTraceId());

if((++i) % 5 == 0)
throw new RuntimeException("test thow exceptions");

return ExecuteResult.success(jobArgs.getTaskBatchId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class XxlJobHandler
@XxlJob("xxlJobHandler1")
public void xxlJobHandler1()
{
log.info("traceId: {}", WebServerHelper.getTraceId());

if((++i) % 5 == 0)
throw new RuntimeException("test thow exceptions");

log.info("traceId: {}", WebServerHelper.getTraceId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.hpsocket.demo.job.service.impl;

import org.springframework.stereotype.Service;

import io.github.hpsocket.soa.starter.job.snailjob.exception.SnailJobExceptionHandler;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class SnailJobExceptionHandlerImpl implements SnailJobExceptionHandler
{
@Override
public void handleException(String jobName, Long jobId, String method, String param, long timestamp, Exception e)
{
log.info("handle snail-job exception : (jobName: {}, jobId: {}, method: {}, param: {}, exception: {})", jobName, jobId, method, param, e);
}

}
7 changes: 6 additions & 1 deletion hp-demo/hp-demo-job/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ spring.cloud.nacos.config:
- group: GLOBAL_GROUP
data-id: xxl-job.yml
refresh: true
- group: GLOBAL_GROUP
data-id: snail-job.yml
refresh: true
- group: GLOBAL_GROUP
data-id: dubbo.yml
refresh: true
Expand All @@ -60,5 +63,7 @@ dubbo.protocols:
# server
server.port: 9101

# xxl-job
# xxl-job port
hp.soa.job.xxl.executor.port: 7101
# snail-job port
snail-job.port: 7501
Loading

0 comments on commit a34c516

Please sign in to comment.