pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388094719


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -17,43 +17,108 @@
 
 package org.apache.eventmesh.runtime.core.protocol;
 
-import org.apache.eventmesh.runtime.core.timer.Timeout;
-import org.apache.eventmesh.runtime.core.timer.Timer;
-import org.apache.eventmesh.runtime.core.timer.TimerTask;
+import org.apache.eventmesh.common.Constants;
+import org.apache.eventmesh.common.config.CommonConfiguration;
+import org.apache.eventmesh.retry.api.conf.RetryConfiguration;
+import org.apache.eventmesh.retry.api.strategy.RetryStrategy;
+import org.apache.eventmesh.retry.api.strategy.StorageRetryStrategy;
+import org.apache.eventmesh.retry.api.timer.Timeout;
+import org.apache.eventmesh.retry.api.timer.TimerTask;
+import org.apache.eventmesh.runtime.core.consumergroup.ConsumerGroupConf;
+import 
org.apache.eventmesh.runtime.core.protocol.consumer.HandleMessageContext;
+import org.apache.eventmesh.runtime.core.protocol.producer.EventMeshProducer;
+import org.apache.eventmesh.runtime.core.protocol.producer.ProducerManager;
+import org.apache.eventmesh.spi.EventMeshExtensionFactory;
 
-import java.util.concurrent.TimeUnit;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
 
 import io.cloudevents.CloudEvent;
 
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
 public abstract class RetryContext implements TimerTask {
 
+    private static final Set<String> STORAGE_RETRY_PROCESSED_EVENT_LIST = 
Collections.synchronizedSet(new HashSet<>());
+
     public CloudEvent event;
 
     public String seq;
 
     public int retryTimes;
 
+    public CommonConfiguration commonConfiguration;
+
     public long executeTime = System.currentTimeMillis();
 
-    public long getExecuteTime() {
-        return executeTime;
+    public void setEvent(CloudEvent event) {
+        this.event = event;
     }
 
-    protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
-        if (timeout == null) {
-            return;
-        }
+    @Override
+    public void setExecuteTimeHook(long executeTime) {
+        this.executeTime = executeTime;
+    }
 
-        Timer timer = timeout.timer();
-        if (timer.isStop() || timeout.isCancelled()) {
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            
Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        String eventMeshStoragePluginType = 
commonConfiguration.getEventMeshStoragePluginType();
+        if (Constants.STANDALONE.equals(eventMeshStoragePluginType)) {
+            log.warn("Storage retry disabled, because of eventmesh storage is 
standalone.");
+            doRun(timeout);
             return;
         }
+        if (eventMeshServerRetryStorageEnabled) {
+            Optional<StorageRetryStrategy> storageRetryStrategy = 
Optional.ofNullable(
+                EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    
commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy());

Review Comment:
   Can the design of this SPI omit the `RetryStrategy` interface and directly 
use `StorageRetryStrategy` (or change its name) as the SPI interface?
   
   这个SPI的设计,是不是可以省去`RetryStrategy`接口,直接用`StorageRetryStrategy`(或者改个名称)作为SPI接口?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to