添加被动消息重试机制
parent
4c51c95bcd
commit
798ab2be7e
@ -0,0 +1,26 @@
|
|||||||
|
package com.docus.server.collect.web.service;
|
||||||
|
|
||||||
|
import com.docus.core.util.json.JSON;
|
||||||
|
import com.docus.log.executor.TrackRetrySpringExecutor;
|
||||||
|
import com.docus.log.handler.IJobHandler;
|
||||||
|
import com.docus.log.handler.MethodJobHandler;
|
||||||
|
import com.docus.server.collect.web.common.entity.TaskOriginalMessage;
|
||||||
|
import org.springframework.retry.annotation.Backoff;
|
||||||
|
import org.springframework.retry.annotation.Retryable;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TrackRetryService {
|
||||||
|
|
||||||
|
@Async("recordMessage")
|
||||||
|
@Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 2000L, multiplier = 1.5))
|
||||||
|
public void doRetry(TaskOriginalMessage message) throws Exception {
|
||||||
|
IJobHandler jobHandler = TrackRetrySpringExecutor.loadJobHandler(message.getRetryKey());
|
||||||
|
String name = ((MethodJobHandler) jobHandler).getMethod().getParameterTypes()[0].getName();
|
||||||
|
Object o = JSON.fromJSON(message.getJsonStr(), Class.forName(name));
|
||||||
|
jobHandler.execute(o);
|
||||||
|
|
||||||
|
//to write retry log
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue