Skip to content

Commit

Permalink
feat(ice): TTR overload listener support generic resolve.
Browse files Browse the repository at this point in the history
  • Loading branch information
yizzuide committed Apr 17, 2020
1 parent 62196be commit c93e9dc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Milkomeda/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<properties>
<java.version>1.8</java.version>
<project.release.version>3.0.9-SNAPSHOT</project.release.version>
<project.release.version>3.0.10-SNAPSHOT</project.release.version>
<spring-boot.version>2.2.4</spring-boot.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
<mybatis.starter.version>2.1.1</mybatis.starter.version>
Expand Down Expand Up @@ -65,7 +65,7 @@
<profile>
<id>sonatype-oss-release</id>
<properties>
<project.release.version>3.0.9</project.release.version>
<project.release.version>3.0.10</project.release.version>
</properties>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
import com.github.yizzuide.milkomeda.universe.metadata.HandlerMetaData;
import com.github.yizzuide.milkomeda.universe.polyfill.RedisPolyfill;
import com.github.yizzuide.milkomeda.util.RedisUtil;
import com.github.yizzuide.milkomeda.util.ReflectUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.util.CollectionUtils;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

/**
* DelayJobHandler
*
* @author yizzuide
* @since 1.15.0
* @version 3.0.8
* @version 3.0.10
* Create at 2019/11/16 17:30
*/
@Slf4j
Expand Down Expand Up @@ -123,6 +125,7 @@ public void run() {
/**
* 处理ttr的任务
*/
@SuppressWarnings("unchecked")
private void processTtrJob(DelayJob delayJob, Job<?> job) {
log.warn("Ice处理TTR的Job {},当前重试次数为{}", delayJob.getJodId(), delayJob.getRetryCount() + 1);
// 检测重试次数过载
Expand All @@ -137,7 +140,7 @@ private void processTtrJob(DelayJob delayJob, Job<?> job) {
handlerMetaDataList.forEach(handlerMetaData -> {
Method method = handlerMetaData.getMethod();
try {
method.invoke(handlerMetaData.getTarget(), job);
ReflectUtil.invokeWithWrapperInject(handlerMetaData.getTarget(), method, Collections.singletonList(job), Job.class, Job::getBody, Job::setBody);
} catch (Exception e) {
log.error("Ice invoke TTR overload listener error: {}", e.getMessage(), e);
}
Expand Down
2 changes: 1 addition & 1 deletion MilkomedaDemo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
<milkomeda.version>3.0.9-SNAPSHOT</milkomeda.version>
<milkomeda.version>3.0.10-SNAPSHOT</milkomeda.version>
<mybatis.starter>2.1.1</mybatis.starter>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import lombok.extern.slf4j.Slf4j;

import java.time.Duration;
import java.util.Map;

/**
* ProductCheckHandler
Expand All @@ -22,9 +21,9 @@ public class ProductCheckHandler {
// 监听topic消息(支持SpEL)
@IceListener(topic = "#target.topicName()")
public Job<Product> handle(Job<Product> productJob) {
log.info("接收到Job: {}", productJob);
// 测试处理失败
// int i = 1 / 0;
log.info("接收到Job: {}", productJob);
// 测试处理失败
// int i = 1 / 0;
// 重新入队到新topic
Product product = productJob.getBody();
product.setDesc("再次审核");
Expand All @@ -43,7 +42,7 @@ public String topicName() {
}

@IceTtrOverloadListener(topic = "#target.topicName()")
public void ttrHandle(Job<Map<String, Object>> job) {
public void ttrHandle(Product job) {
log.error("trr overload with job: {}", job);
}
}

0 comments on commit c93e9dc

Please sign in to comment.