You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by "yanrongzhen (via GitHub)" <gi...@apache.org> on 2023/11/06 13:36:56 UTC

[PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

yanrongzhen opened a new pull request, #4544:
URL: https://github.com/apache/eventmesh/pull/4544

   ### Modifications
   Provide MQ-storage-based retry strategy in http protocol.


-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388179847


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   > Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   > 
   > 那为`rePut()`预留的`doRun(Timeout)` <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?
   
   Also, the rePut method I think will be re-added soon in the future, and it is a common practice to resubmit to the hashed time wheel when the retry process fails.
   
   ---
   
   并且, rePut方法我认为在未来很快会被重新添加回来, 在重试过程中产生失败时, 重新提交到时间轮是一个很常见的做法.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   > Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   > 
   > 那为`rePut()`预留的`doRun(Timeout)` <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?
   
   Also, the rePut method I think will be re-added soon in the future, and it is a common practice to resubmit to the hashed time wheel when the retry process fails.
   
   ---
   
   并且, rePut方法我认为在未来很快会被重新添加回来, 在重试过程中产生失败时, 重新提交到时间轮是一个很常见的做法.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388175983


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   I personally think it's okay to keep it. Other simillar middleware does the same.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388171836


##########
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:
   The current design is to extend Retry's other SPIs in the future. You can understand that RetryStrategy is an SPI facade interface.
   
   ---
   
   目前的设计是为了今后可以扩展Retry的其他SPI, 你可以理解为RetryStrategy是一个SPI门面接口.



##########
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:
   The current design is to extend Retry's other SPIs in the future. You can understand that RetryStrategy is an SPI facade interface.
   
   ---
   
   目前的设计是为了今后可以扩展Retry的其他SPI, 你可以理解为RetryStrategy是一个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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388715716


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   >  the rePut method I think will be re-added soon in the future
   
   This is certainly very good. Could you add a `Timeout` parameter to `doRun()` and `run()` when the `reput` is re-added? It is beneficial for both the community and the project to keep open source code in a clear and tidy state for iteration as much as possible.
   
   这非常好。那能不能在`rePut`被重新添加回来时,再给`doRun()`和`run()`加上`Timeout`入参呢?让开源代码尽量保持清晰、整洁的状态进行迭代,对社区对项目都是有益的。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   >  the rePut method I think will be re-added soon in the future
   
   This is certainly very good. Could you add a `Timeout` parameter to `doRun()` and `run()` when the `reput` is re-added? It is beneficial for both the community and the project to keep open source code in a clear and tidy state for iteration as much as possible.
   
   这非常好。那能不能在`rePut`被重新添加回来时,再给`doRun()`和`run()`加上`Timeout`入参呢?让开源代码尽量保持清晰、整洁的状态进行迭代,对社区对项目都是有益的。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1384989412


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   
   This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   
   ---
   将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。
   这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   I didn't understand this `maxTimesPerEvent`. When `maxTimesPerEvent<1`, send to the retry queue of MQ. When `maxTimesPerEvent ≥ 1`, it is directly processed as successful consumption. What does this variable record?
   
   ---
   这个`maxTimesPerEvent`没看明白。`maxTimesPerEvent < 1`时,发到MQ的重试队列。`maxTimesPerEvent ≥ 1`时,直接处理为消费成功。该变量是记录什么的?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   I didn't understand this `maxTimesPerEvent`. When `maxTimesPerEvent<1`, send to the retry queue of MQ. When `maxTimesPerEvent ≥ 1`, it is directly processed as successful consumption. What does this variable record?
   
   ---
   这个`maxTimesPerEvent`没看明白。`maxTimesPerEvent < 1`时,发到MQ的重试队列。`maxTimesPerEvent ≥ 1`时,直接处理为消费成功。该变量是记录什么的?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   
   This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   
   ---
   将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。
   这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386138028


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   I optimized this in a new round of commits.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386139816


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   Used to control the number of consumption, since the retry-topic method is used for retrying, failure to control may result in unlimited repeated consumption.
   
   ---
   
   用于控制消费次数, 由于使用了retry-topic的方式进行重试, 不进行控制可能会导致无限制重复消费.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   Used to control the number of consumption, since the retry-topic method is used for retrying, failure to control may result in unlimited repeated consumption.
   
   ---
   
   用于控制消费次数, 由于使用了retry-topic的方式进行重试, 不进行控制可能会导致无限制重复消费.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386308831


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   This dependency is redundant. If this dependency is needed, decoupling cannot be achieved.
   
   这个依赖是多余的。如果需要该依赖,就做不到解耦了。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   Suggest modifying the method name, as the logic of `doRun()` and the remaining logic of the `run()` method are juxtaposed. Just one is based on the retry function provided by external storage, and the other is the in memory retry provided by EventMesh.
   
   建议修改下该方法名,因为doRun()的逻辑和该run()方法剩下的逻辑是并列的。只不过一个是基于外部存储提供的重试功能,一个是EventMesh提供的内存中重试。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   Based on your code, there is no need to use Map<String, Integer>to increase logical complexity. Because the Integer of this Map only stores 0 and 1, using Set is sufficient. If not in the Set set, add it and follow the retry logic. If there is one in the Set, it is directly processed as successful consumption.
   
   根据你的代码,没必要用Map<String, Integer>增加逻辑复杂性。因为该Map的Integer只存0和1,所以用Set就够了。Set集合中没有则添加进去,然后走重试逻辑;集合中有,直接处理为消费成功。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java:
##########
@@ -27,17 +27,24 @@ public class ConsumerGroupConf implements Serializable {
     // eg . 5013-1A0
     private String consumerGroup;
 
+    private String topic;
+
     private final ConcurrentHashMap<String/* topic */, ConsumerGroupTopicConf> consumerGroupTopicConf =

Review Comment:
   The original `ConsumerGroupConf` can store multiple topics. It is also common for a consumption group to correspond to multiple topics. Would it be appropriate if you changed it to only store one topic?
   
   原来的`ConsumerGroupConf`,可以存储多个topic。一个消费组对应多个topic也很常见。你将其改成了只能存储一个topic,是否合适?



##########
eventmesh-storage-plugin/eventmesh-storage-api/src/main/java/org/apache/eventmesh/api/TopicNameHelper.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+import org.apache.eventmesh.spi.EventMeshExtensionType;
+import org.apache.eventmesh.spi.EventMeshSPI;
+
+import lombok.SneakyThrows;
+
+/**
+ * Topic name generator.
+ */
+@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.STORAGE)
+public interface TopicNameHelper {
+
+    @SneakyThrows
+    default String generateRetryTopicName(String topicName) {
+        throw new IllegalAccessException("Method not supported.");
+    }

Review Comment:
   This method is no longer used in your new submission.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/producer/SendMessageContext.java:
##########
@@ -44,14 +46,16 @@ public class SendMessageContext extends RetryContext {
 
     private long createTime = System.currentTimeMillis();
 
-    public EventMeshGrpcServer eventMeshGrpcServer;
+    public AbstractRemotingServer eventMeshServer;
+
+    private List<CloudEvent> eventList;

Review Comment:
   Redundant attribute and corresponding setter getter.



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   This dependency is redundant. If this dependency is needed, decoupling cannot be achieved.
   
   这个依赖是多余的。如果需要该依赖,就做不到解耦了。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/consumergroup/ConsumerGroupConf.java:
##########
@@ -27,17 +27,24 @@ public class ConsumerGroupConf implements Serializable {
     // eg . 5013-1A0
     private String consumerGroup;
 
+    private String topic;
+
     private final ConcurrentHashMap<String/* topic */, ConsumerGroupTopicConf> consumerGroupTopicConf =

Review Comment:
   The original `ConsumerGroupConf` can store multiple topics. It is also common for a consumption group to correspond to multiple topics. Would it be appropriate if you changed it to only store one topic?
   
   原来的`ConsumerGroupConf`,可以存储多个topic。一个消费组对应多个topic也很常见。你将其改成了只能存储一个topic,是否合适?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/producer/EventMeshProducer.java:
##########
@@ -102,4 +105,16 @@ public String toString() {
             .append(producerGroupConfig).append("}");
         return sb.toString();
     }
+
+    public MQProducerWrapper getMqProducerWrapper() {
+        return mqProducerWrapper;
+    }
+
+    public boolean isInited() {

Review Comment:
   Redundant method.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   Suggest modifying the method name, as the logic of `doRun()` and the remaining logic of the `run()` method are juxtaposed. Just one is based on the retry function provided by external storage, and the other is the in memory retry provided by EventMesh.
   
   建议修改下该方法名,因为doRun()的逻辑和该run()方法剩下的逻辑是并列的。只不过一个是基于外部存储提供的重试功能,一个是EventMesh提供的内存中重试。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   Based on your code, there is no need to use Map<String, Integer>to increase logical complexity. Because the Integer of this Map only stores 0 and 1, using Set is sufficient. If not in the Set set, add it and follow the retry logic. If there is one in the Set, it is directly processed as successful consumption.
   
   根据你的代码,没必要用Map<String, Integer>增加逻辑复杂性。因为该Map的Integer只存0和1,所以用Set就够了。Set集合中没有则添加进去,然后走重试逻辑;集合中有,直接处理为消费成功。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387814835


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > This is because the runtime needs to be loaded into a specific middleware SPI implementation
   
   When using standalone mode, even if `retry.storageEnabled` is configured to true, we can directly use the retry in memory provided by EventMesh without the need to load the specific implementation of SPI. Of course, at this point, a log can be provided to prompt the user that `retry.storageEnabled` does not work because they are using standalone mode.
   
   In addition, when it is not standalone and `retry. storageEnabled` is configured to true, if the specific implementation of SPI cannot be loaded, the user will be prompted by printing a log, and then  we use the retry in memory provided by EventMesh as a backup.
   
   This can achieve more thorough decoupling, wouldn't it be better?
   
   当使用standalone模式时,即使`retry.storageEnabled`配置为true,就可以直接采用EventMesh提供的内存中重试,而不必加载SPI的具体实现。当然这时可以给出日志提示用户因为使用standalone模式,所以`retry.storageEnabled`不起作用。
   另外还可以在非standalone且`retry.storageEnabled`配置为true时,如果加载不到SPI的具体实现,打印日志提示用户以后,就采用EventMesh提供的内存中重试作为一种兜底。
   这样可以做到更彻底的解耦,不是更好吗?



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > This is because the runtime needs to be loaded into a specific middleware SPI implementation
   
   When using standalone mode, even if `retry.storageEnabled` is configured to true, we can directly use the retry in memory provided by EventMesh without the need to load the specific implementation of SPI. Of course, at this point, a log can be provided to prompt the user that `retry.storageEnabled` does not work because they are using standalone mode.
   
   In addition, when it is not standalone and `retry. storageEnabled` is configured to true, if the specific implementation of SPI cannot be loaded, the user will be prompted by printing a log, and then  we use the retry in memory provided by EventMesh as a backup.
   
   This can achieve more thorough decoupling, wouldn't it be better?
   
   当使用standalone模式时,即使`retry.storageEnabled`配置为true,就可以直接采用EventMesh提供的内存中重试,而不必加载SPI的具体实现。当然这时可以给出日志提示用户因为使用standalone模式,所以`retry.storageEnabled`不起作用。
   另外还可以在非standalone且`retry.storageEnabled`配置为true时,如果加载不到SPI的具体实现,打印日志提示用户以后,就采用EventMesh提供的内存中重试作为一种兜底。
   这样可以做到更彻底的解耦,不是更好吗?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388108048


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391891056


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   The relationship between the retry strategy plugin and storage can be reflected in the document, and there is no need to strongly bind the configuration name and code logic. I think everyone can understand this.
   
   ---
   重试策略插件与使用的存储的关系,可以体现在文档中,不用在配置名称和代码逻辑上强绑定。这点我想大家也是都能理解的。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   The relationship between the retry strategy plugin and storage can be reflected in the document, and there is no need to strongly bind the configuration name and code logic. I think everyone can understand this.
   
   ---
   重试策略插件与使用的存储的关系,可以体现在文档中,不用在配置名称和代码逻辑上强绑定。这点我想大家也是都能理解的。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388168285


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I don't think this dependency should be removed. If it is removed, the SPI will not take effect when the user specifies storage = rocketmq.
   
   ---
   
   我觉得不应该删除此依赖, 如果删除, 当用户指定了storage=rocketmq的时候, 将不会生效此SPI.



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I don't think this dependency should be removed. If it is removed, the SPI will not take effect when the user specifies storage = rocketmq.
   
   ---
   
   我觉得不应该删除此依赖, 如果删除, 当用户指定了storage=rocketmq的时候, 将不会生效此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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387984712


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   Waiting for your reply.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1390992277


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I think you may want to decouple the retry plugin and storage plugin. However, when the retry plugin is non standalone, the specific configuration of the storage medium for the retry strategy currently still uses the configuration of the EventMesh message storage medium.
   
   我觉得你可能是想将retry plugin和storage plugin解耦。但是当retry plugin是非standalone时,目前重试策略的存储介质的具体配置仍然使用的是EventMesh消息存储介质的配置。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -64,44 +63,35 @@ public void setExecuteTimeHook(long executeTime) {
 
     @Override
     public final void run() throws Exception {
-        boolean eventMeshServerRetryStorageEnabled =
-            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
-                .orElse(false);
-        String eventMeshStoragePluginType = commonConfiguration.getEventMeshStoragePluginType();
-        if (Constants.STANDALONE.equals(eventMeshStoragePluginType)) {
-            log.warn("Because eventmesh storage is standalone, 'retry.storageEnable' will be ignored.");
+        String eventMeshRetryPluginType = Optional.ofNullable(commonConfiguration.getEventMeshRetryPluginType())
+            .orElse(Constants.STANDALONE);
+        if (Constants.STANDALONE.equals(eventMeshRetryPluginType)) {
+            log.warn("Because eventmesh storage is standalone or null, retry in memory.");

Review Comment:
   After separating the retry plugin and storage plugin, it would be better to write this log as `... retry plugin is standalone...`.
   
   你将retry plugin和storage plugin分开后,这个日志最好写成`... retry plugin is standalone ...`。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I think you may want to decouple the retry plugin and storage plugin. However, when the retry plugin is non standalone, the specific configuration of the storage medium for the retry strategy currently still uses the configuration of the EventMesh message storage medium.
   
   我觉得你可能是想将retry plugin和storage plugin解耦。但是当retry plugin是非standalone时,目前重试策略的存储介质的具体配置仍然使用的是EventMesh消息存储介质的配置。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -64,44 +63,35 @@ public void setExecuteTimeHook(long executeTime) {
 
     @Override
     public final void run() throws Exception {
-        boolean eventMeshServerRetryStorageEnabled =
-            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
-                .orElse(false);
-        String eventMeshStoragePluginType = commonConfiguration.getEventMeshStoragePluginType();
-        if (Constants.STANDALONE.equals(eventMeshStoragePluginType)) {
-            log.warn("Because eventmesh storage is standalone, 'retry.storageEnable' will be ignored.");
+        String eventMeshRetryPluginType = Optional.ofNullable(commonConfiguration.getEventMeshRetryPluginType())
+            .orElse(Constants.STANDALONE);
+        if (Constants.STANDALONE.equals(eventMeshRetryPluginType)) {
+            log.warn("Because eventmesh storage is standalone or null, retry in memory.");

Review Comment:
   After separating the retry plugin and storage plugin, it would be better to write this log as `... retry plugin is standalone...`.
   
   你将retry plugin和storage plugin分开后,这个日志最好写成`... retry plugin is standalone ...`。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388813649


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I rollbacked the dependency changes, and then i will resubmit it after we are done discussing it.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391961519


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   In this submission, the author changed the writing of the retry configuration from `retry.storageEnabled=false` to `retry.plugin.type=standalone(default)`. The idea is very good, which separates the configuration of the retry plugin and the storage plugin. However, as far as the current code is concerned, new issues may arise. For example, if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=rabbitmq`, but the retry plugin is actually connected to the address of rabbitmq (retry will also fail), or if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=standalone`, the retry plugin is actually 'connected' to memory (retry will also fail). So this actually makes `retry.plugin.type=standalone(default)` not as good as previous `retry.storageEnabled=false`.
   
   I would like to know your views on this point. @yanrongzhen @xwm1992 
   
   作者在该提交中,将retry配置的写法从`retry.storageEnabled=false`改成了`retry.plugin.type=standalone(default)`。思路是很好的,这样将retry插件和storage插件的配置隔离开。但是就目前的代码而言会出现新的问题。比如用户的配置是`retry.plugin.type=rocketmq`和`storage.plugin.type=rabbitmq`,但其实retry插件连接是rabbitmq的地址(重试也将失效),或者用户配置的是`retry.plugin.type=rocketmq`和`storage.plugin.type=standalone`,其实retry插件“连接”的是内存(重试也将失效)。所以这反而使得`retry.plugin.type=standalone(default)`没有之前`retry.storageEnabled=false`好。
   就这一点,我想听下你们的看法。@yanrongzhen @xwm1992 



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 merged PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544


-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387984712


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   Waiting for your feedback.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388859877


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   In fact, if the runtime does not show the addition of dependencies, it means that users need to load the dependencies of this SPI implementation by themselves. I am worried that it will create a greater burden for users.
   
   ---
   
   其实如果runtime不显示加入依赖, 就代表了用户需要自行去加载这个SPI实现的依赖, 我担心对于用户会产生更大的负担,



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   In fact, if the runtime does not show the addition of dependencies, it means that users need to load the dependencies of this SPI implementation by themselves. I am worried that it will create a greater burden for users.
   
   ---
   
   其实如果runtime不显示加入依赖, 就代表了用户需要自行去加载这个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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388175983


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   I personally think it's okay to keep it.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1805161337

   @pandaapo 
   
   I used the plugin method to solve the dependency problem discussed before, please review it again, thanks.
   
   ---
   
   我使用了plugin方式来解决了之前讨论的依赖的问题, 帮忙再review一下, 谢谢


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386435047


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }

Review Comment:
   Based on your code, there is no need to use Map<String, Integer>to increase logical complexity. Because the Integer of this Map only stores 0 and 1, using Set is sufficient. If not in the Set set, add it and follow the retry logic. If there is one in the Set, it is directly processed as successful consumption.
   
   根据你的代码,没必要用Map<String, Integer>增加逻辑复杂性。因为该Map的Integer只存0和1,所以用Set就够了。Set集合中没有则添加进去,然后走重试逻辑;集合中有,直接处理为消费成功。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }

Review Comment:
   Based on your code, there is no need to use Map<String, Integer>to increase logical complexity. Because the Integer of this Map only stores 0 and 1, using Set is sufficient. If not in the Set set, add it and follow the retry logic. If there is one in the Set, it is directly processed as successful consumption.
   
   根据你的代码,没必要用Map<String, Integer>增加逻辑复杂性。因为该Map的Integer只存0和1,所以用Set就够了。Set集合中没有则添加进去,然后走重试逻辑;集合中有,直接处理为消费成功。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1797894866

   > Could you explain how this PR solves the problem described in issue #4178? Because most of the code I see seems to be a unified and abstract refactoring of the code related to the grpc, http, and tcp modules.
   > 
   > 能否解释下该PR是怎么解决issue #4178所描述的问题?因为我看到的代码好像大部分是给grpc、http、tcp三个模块相关代码做统一和抽象的重构工作。
   
   Waiting for your reply.


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1797923873

   > > Could you explain how this PR solves the problem described in issue #4178? Because most of the code I see seems to be a unified and abstract refactoring of the code related to the grpc, http, and tcp modules.
   > > 能否解释下该PR是怎么解决issue #4178所描述的问题?因为我看到的代码好像大部分是给grpc、http、tcp三个模块相关代码做统一和抽象的重构工作。
   > 
   > Waiting for your reply.
   
   First of all, the goal of this PR is to provide the ability to retry in the MQ retry queue within the Retry module.
   Here are two changes made:
   1. The `EventMeshProducer`, `ProducerManager`, and `SendMessageContext` of each protocol have been standardized. The reason for this change is that Retry should be a standard processing method, regardless of the specific underlying protocol, and the usage of these three protocols is completely consistent, so they are merged.
   
   2. In RetryContext, when the user turns on the switch, the message is sent to the retry queue asynchronously to retry.
   
   ---
   
   首先, 此PR的目标是在Retry模块内部提供于MQ重试队列来进行重试的能力.
   这里做了两个改动:
   1. 对于各协议的EventMeshProducer, ProducerManager, SendMessageContext进行了标准化, 此改动的原因是Retry应该是一个标准的处理方式, 而不关心具体底层的协议, 并且这三者在各协议的用法完全一致, 因此进行了合并处理.
   2. 在RetryContext中, 在用户打开开关时, 支持将消息异步发送至重试队列中, 以达到重试的效果.
   
   


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388776997


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I think you are right. I removed the dependency just now.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388108048


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388725828


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   According to this comment https://github.com/apache/eventmesh/pull/4544#discussion_r1387814835, adding a backup strategy and adding log prompts is just to decouple runtime and specific storage more thoroughly? If we implement retry-rabbitmq and retry-kafka in the later stage, shouldn't we also include them?
   
   When users see logs that have been selected as standalone or have not been loaded into the SPI implementation, they naturally know that corresponding dependencies need to be introduced. It can even make the logs clearer and prompt users to introduce corresponding storage retry dependency or implement their own SPI for storage retries.
   
   To avoid further arguments, it's better to ask the maintainer to decide whether to keep this dependency in runtime module. @xwm1992.
   
   https://github.com/apache/eventmesh/blob/44484350365c28567f17c7d4ffc1c68232ce05f3/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java#L68-L85
   
   根据这条评论 https://github.com/apache/eventmesh/pull/4544#discussion_r1387814835 ,增加兜底策略、增加日志提示,不就是为了runtime和具体的存储更彻底的解耦吗?后期如果实现了retry-rabbitmq、retry-kafka岂不是也要加进来?
   当用户看到因为选择了standalone或者没有加载到SPI实现的日志时,自然就知道需要引入相应的依赖。甚至可以让日志更明确些,提示用户引入相应的存储重试依赖或者自己实现存储重试的SPI。
   为了避免更多的争论,还是请maintainer来决定是否在runtime模块中保留该依赖吧。@xwm1992。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1385860254


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   > Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   > 
   > This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   > 
   > 将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。 这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992
   
   是的,这个pr的主要修改点在于支持扩展不同的重试策略,将依赖存储的重试策略与eventmesh解耦



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   > Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   > 
   > This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   > 
   > 将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。 这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992
   
   是的,这个pr的主要修改点在于支持扩展不同的重试策略,将依赖存储的重试策略与eventmesh解耦



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386138028


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   I optimized this issue in a new round of commits.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387849035


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is my question. Seeing such code, the passed in timeout was not used. So is this indicating that the refactoring of retry in memory using `HashedWheelTimer` was incomplete before, or is it due to inheritance system design?
   
   这是我的一个疑问。看到多出这样的代码,没有使用传入的Timeout。所以这是表示之前用`HashedWheelTimer`对内存中重试的重构不完全,还是继承体系设计的原因?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is my question. Seeing such code, the passed in timeout was not used. So is this indicating that the refactoring of retry in memory using `HashedWheelTimer` was incomplete before, or is it due to inheritance system design?
   
   这是我的一个疑问。看到多出这样的代码,没有使用传入的Timeout。所以这是表示之前用`HashedWheelTimer`对内存中重试的重构不完全,还是继承体系设计的原因?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1385901955


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   So that is to say, this PR and PR #4179 have a similar problem, limiting the stored retry strategy to RocketMQ and making it difficult to expand to other middleware.
   
   所以也就是说,这个PR和PR #4179存在类似的问题,将存储的重试策略限制在了RocketMQ上,难以拓展到其他中间件。



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   So that is to say, this PR and PR #4179 have a similar problem, limiting the stored retry strategy to RocketMQ and making it difficult to expand to other middleware.
   
   所以也就是说,这个PR和PR #4179存在类似的问题,将存储的重试策略限制在了RocketMQ上,难以拓展到其他中间件。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1385860254


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   > Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   > 
   > This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   > 
   > 将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。 这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992
   
   Yes, the main modification point of this pr is to support the expansion of different retry strategies and decouple the storage-dependent retry strategy from eventmesh
   
   ---
   是的,这个pr的主要修改点在于支持扩展不同的重试策略,将依赖存储的重试策略与eventmesh解耦



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388814193


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   The core question may be whether the user needs to declare the retry-rocketmq dependency.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388008177


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > Waiting for your reply.
   
   Optimized in a new commit.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388725828


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   According to this comment https://github.com/apache/eventmesh/pull/4544/#discussion_r1387814835, adding a backup strategy and adding log prompts is just to decouple runtime and specific storage more thoroughly? If we implement retry-rabbitmq and retry-kafka in the later stage, shouldn't we also include them?
   
   When users see logs that have been selected as standalone or have not been loaded into the SPI implementation, they naturally know that corresponding dependencies need to be introduced. It can even make the logs clearer and prompt users to introduce corresponding storage retry dependency or implement their own SPI for storage retries.
   
   To avoid further arguments, it's better to ask the maintainer to decide whether to keep this dependency in runtime module. @xwm1992.
   
   https://github.com/apache/eventmesh/blob/44484350365c28567f17c7d4ffc1c68232ce05f3/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java#L68-L85
   
   根据这条评论 https://github.com/apache/eventmesh/pull/4544/#discussion_r1387814835 ,增加兜底策略、增加日志提示,不就是为了runtime和具体的存储更彻底的解耦吗?后期如果实现了retry-rabbitmq、retry-kafka岂不是也要加进来?
   当用户看到因为选择了standalone或者没有加载到SPI实现的日志时,自然就知道需要引入相应的依赖。甚至可以让日志更明确些,提示用户引入相应的存储重试依赖或者自己实现存储重试的SPI。
   为了避免更多的争论,还是请maintainer来决定是否在runtime模块中保留该依赖吧。@xwm1992。



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   According to this comment https://github.com/apache/eventmesh/pull/4544/#discussion_r1387814835, adding a backup strategy and adding log prompts is just to decouple runtime and specific storage more thoroughly? If we implement retry-rabbitmq and retry-kafka in the later stage, shouldn't we also include them?
   
   When users see logs that have been selected as standalone or have not been loaded into the SPI implementation, they naturally know that corresponding dependencies need to be introduced. It can even make the logs clearer and prompt users to introduce corresponding storage retry dependency or implement their own SPI for storage retries.
   
   To avoid further arguments, it's better to ask the maintainer to decide whether to keep this dependency in runtime module. @xwm1992.
   
   https://github.com/apache/eventmesh/blob/44484350365c28567f17c7d4ffc1c68232ce05f3/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java#L68-L85
   
   根据这条评论 https://github.com/apache/eventmesh/pull/4544/#discussion_r1387814835 ,增加兜底策略、增加日志提示,不就是为了runtime和具体的存储更彻底的解耦吗?后期如果实现了retry-rabbitmq、retry-kafka岂不是也要加进来?
   当用户看到因为选择了standalone或者没有加载到SPI实现的日志时,自然就知道需要引入相应的依赖。甚至可以让日志更明确些,提示用户引入相应的存储重试依赖或者自己实现存储重试的SPI。
   为了避免更多的争论,还是请maintainer来决定是否在runtime模块中保留该依赖吧。@xwm1992。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388789158


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   
   我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢你及时的回应。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388043610


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   OK, I removed this method in the new commit.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Sure, I removed this method in the new commit.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1805386435

   > I used the plugin method to solve the dependency problem discussed before
    
   Your idea is better than mine.


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388775500


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Parameter has been removed.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387849035


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is my question. Seeing such code, the passed in timeout was not used. So is this indicating that the refactoring of retry in memory using `HashedWheelTimer` was incomplete before, or is it due to inheritance system design?
   
   这是我的一个疑问。看到多出这样的代码,没有使用传入的Timeout。所以这是表示之前用`HashedWheelTimer`对内存中重试的重构不完全,还是继承体系设计的原因?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388003695


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   But this `reput()` method also has no use at all. Could this method be removed to make the code clearer and less confusing for developers and readers?
   
   但是这个`rePut()`方法也是没有任何使用的地方。该方法能否优化掉,从而让代码更清楚一些,让开发者和阅读者少些困惑?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   But this `reput()` method also has no use at all. Could this method be removed to make the code clearer and less confusing for developers and readers?
   
   但是这个`rePut()`方法也是没有任何使用的地方。该方法能否优化掉,从而让代码更清楚一些,让开发者和阅读者少些困惑?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1795025252

   ## [Codecov](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#4544](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (a3e263c) into [master](https://app.codecov.io/gh/apache/eventmesh/commit/7438a5542e376f75d3c3f38bfae123cf2be3c7cc?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (7438a55) will **increase** coverage by `0.01%`.
   > The diff coverage is `1.98%`.
   
   > :exclamation: Current head a3e263c differs from pull request most recent head 6276b83. Consider uploading reports for the commit 6276b83 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #4544      +/-   ##
   ============================================
   + Coverage     16.14%   16.16%   +0.01%     
     Complexity     1581     1581              
   ============================================
     Files           747      745       -2     
     Lines         28965    28906      -59     
     Branches       2541     2537       -4     
   ============================================
   - Hits           4677     4673       -4     
   + Misses        23840    23782      -58     
   - Partials        448      451       +3     
   ```
   
   
   | [Files](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...e/eventmesh/common/config/CommonConfiguration.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9jb25maWcvQ29tbW9uQ29uZmlndXJhdGlvbi5qYXZh) | `83.92% <100.00%> (+0.59%)` | :arrow_up: |
   | [...tmesh/common/protocol/http/common/ProtocolKey.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi9wcm90b2NvbC9odHRwL2NvbW1vbi9Qcm90b2NvbEtleS5qYXZh) | `95.45% <ø> (ø)` | |
   | [...rg/apache/eventmesh/common/utils/ReflectUtils.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLWNvbW1vbi9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZXZlbnRtZXNoL2NvbW1vbi91dGlscy9SZWZsZWN0VXRpbHMuamF2YQ==) | `90.00% <ø> (ø)` | |
   | [...he/eventmesh/runtime/boot/EventMeshHTTPServer.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2Jvb3QvRXZlbnRNZXNoSFRUUFNlcnZlci5qYXZh) | `0.71% <ø> (ø)` | |
   | [...time/configuration/EventMeshHTTPConfiguration.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvbmZpZ3VyYXRpb24vRXZlbnRNZXNoSFRUUENvbmZpZ3VyYXRpb24uamF2YQ==) | `88.05% <ø> (ø)` | |
   | [...core/protocol/grpc/consumer/EventMeshConsumer.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9jb25zdW1lci9FdmVudE1lc2hDb25zdW1lci5qYXZh) | `0.00% <ø> (ø)` | |
   | [...rpc/processor/BatchPublishCloudEventProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvQmF0Y2hQdWJsaXNoQ2xvdWRFdmVudFByb2Nlc3Nvci5qYXZh) | `0.00% <ø> (ø)` | |
   | [...ol/grpc/processor/PublishCloudEventsProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvUHVibGlzaENsb3VkRXZlbnRzUHJvY2Vzc29yLmphdmE=) | `0.00% <ø> (ø)` | |
   | [...protocol/grpc/processor/ReplyMessageProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvUmVwbHlNZXNzYWdlUHJvY2Vzc29yLmphdmE=) | `0.00% <ø> (ø)` | |
   | [...col/grpc/processor/RequestCloudEventProcessor.java](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-ZXZlbnRtZXNoLXJ1bnRpbWUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2V2ZW50bWVzaC9ydW50aW1lL2NvcmUvcHJvdG9jb2wvZ3JwYy9wcm9jZXNzb3IvUmVxdWVzdENsb3VkRXZlbnRQcm9jZXNzb3IuamF2YQ==) | `0.00% <ø> (ø)` | |
   | ... and [26 more](https://app.codecov.io/gh/apache/eventmesh/pull/4544?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   ... and [9 files with indirect coverage changes](https://app.codecov.io/gh/apache/eventmesh/pull/4544/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in [Chrome](https://chrome.google.com/webstore/detail/codecov/gedikamndpbemklijjkncpnolildpbgo) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/codecov/) today!
   


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391888528


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I understand that the original intention here is to use the `default` strategy. There is no need to reflect it as standalone. It can be marked as default. Others, such as rocketmq and rabbitmq, can have different retry strategies. `eventMeshRetryPluginType = “default”;` That’s fine. @pandaapo @yanrongzhen 
   
   ---
   我理解这里的本意是走默认的策略,没必要体现是standalone,可以标识为default,其他例如rocketmq,rabbitmq,可以有不同的重试策略实现,`eventMeshRetryPluginType = “default”;` 这样就好。 @pandaapo @yanrongzhen 



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I understand that the original intention here is to use the `default` strategy. There is no need to reflect it as standalone. It can be marked as default. Others, such as rocketmq and rabbitmq, can have different retry strategies. `eventMeshRetryPluginType = “default”;` That’s fine. @pandaapo @yanrongzhen 
   
   ---
   我理解这里的本意是走默认的策略,没必要体现是standalone,可以标识为default,其他例如rocketmq,rabbitmq,可以有不同的重试策略实现,`eventMeshRetryPluginType = “default”;` 这样就好。 @pandaapo @yanrongzhen 



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1392198349


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   Yes, there will be coupling, so either there are relevant descriptions in the document guidelines to make it clear to users, or coupling judgment processing must be carried out in the code. The judgment conditions are: if the retry strategy is used or the corresponding The storage module is the same, or it is the default strategy.
   
   ---
   是的,是会存在耦合的情况,所以要么文档指引中有相关描述,让使用人清楚,要么就是要在代码中进行耦合的判断处理,判断的条件就是:如果使用了重试策略要么与对应的storage模块相同,要么就是default策略。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   Yes, there will be coupling, so either there are relevant descriptions in the document guidelines to make it clear to users, or coupling judgment processing must be carried out in the code. The judgment conditions are: if the retry strategy is used or the corresponding The storage module is the same, or it is the default strategy.
   
   ---
   是的,是会存在耦合的情况,所以要么文档指引中有相关描述,让使用人清楚,要么就是要在代码中进行耦合的判断处理,判断的条件就是:如果使用了重试策略要么与对应的storage模块相同,要么就是default策略。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#issuecomment-1809831971

   I resubmitted the code based on the latest code review, please help to review it again, thanks.


-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1392077697


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I understand that the current modification has nothing to do with `standalone`. If the `retry strategy` is configured, the corresponding configuration will be used. If the configuration is not loaded, the `default strategy` will be used. For the situation the rocketmq strategy is used, but the rabbitmq is used for storage. Just mark it in the documentation guide, or add a judgment to determine whether the strategy matches the storage, or throw a clear mismatch exception.
   
   ---
   我理解目前的修改与`standalone` 没什么关系了,配置了`retry策略`就是走对应配置的,如果配置的没加载到就是走`default策略`,对于使用retry策略使用的`rocketmq策略`,但是存储使用的rabbitmq的这种情况,在文档指引中体现标识一下就行了,或者就是加一个策略与存储是否匹配的判断,抛出一个明确的不匹配的异常也可以。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   I understand that the current modification has nothing to do with `standalone`. If the `retry strategy` is configured, the corresponding configuration will be used. If the configuration is not loaded, the `default strategy` will be used. For the situation the rocketmq strategy is used, but the rabbitmq is used for storage. Just mark it in the documentation guide, or add a judgment to determine whether the strategy matches the storage, or throw a clear mismatch exception.
   
   ---
   我理解目前的修改与`standalone` 没什么关系了,配置了`retry策略`就是走对应配置的,如果配置的没加载到就是走`default策略`,对于使用retry策略使用的`rocketmq策略`,但是存储使用的rabbitmq的这种情况,在文档指引中体现标识一下就行了,或者就是加一个策略与存储是否匹配的判断,抛出一个明确的不匹配的异常也可以。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1384289971


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/http/push/AsyncHTTPPushRequest.java:
##########
@@ -91,7 +93,8 @@ public AsyncHTTPPushRequest(HandleMsgContext handleMsgContext,
     @Override
     public void tryHTTPRequest() {
 
-        currPushUrl = getUrl();
+        // currPushUrl = getUrl();
+        currPushUrl = "http://127.0.0.2:8088/sub/test";

Review Comment:
   "http://127.0.0.2:8088/sub/test"?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "xwm1992 (via GitHub)" <gi...@apache.org>.
xwm1992 commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1385860254


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMessageContext getHandleMessageContext() throws Exception {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    public abstract void doRun(Timeout timeout) throws Exception;
+
+    @SneakyThrows
+    protected ProducerManager getProducerManager() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    @SneakyThrows
+    protected ConsumerGroupConf getConsumerGroupConf() {
+        throw new IllegalAccessException("method not supported.");
+    }
+
+    private void sendMessageBack(final CloudEvent event) throws Exception {
+        String topic = event.getSubject();
+        String bizSeqNo = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.BIZSEQNO.getKey())).toString();
+        String uniqueId = Objects.requireNonNull(event.getExtension(ProtocolKey.ClientInstanceKey.UNIQUEID.getKey())).toString();
+
+        ConsumerGroupConf consumerGroupConf = getConsumerGroupConf();
+        String consumerGroupName = consumerGroupConf.getConsumerGroup();
+        EventMeshProducer sendMessageBack = getProducerManager().getEventMeshProducer(consumerGroupName);
+
+        if (sendMessageBack == null) {
+            log.warn("consumer:{} consume fail, sendMessageBack, topic:{}, bizSeqNo:{}, uniqueId:{}",
+                consumerGroupName, topic, bizSeqNo, uniqueId);
+            return;
+        }
+        TopicNameHelper topicNameGenerator = EventMeshExtensionFactory.getExtension(TopicNameHelper.class,
+            commonConfiguration.getEventMeshStoragePluginType());
+        String retryTopicName = topicNameGenerator.generateRetryTopicName(consumerGroupName);

Review Comment:
   > Send the message to the MQ retry queue for retry, more accurately RocketMQ. Because other mainstream MQ does not have a retry queue like RocketMQ, for example, RabbitMQ's retry queue is a regular queue that is only controlled through the `x-max-retries` attribute in the message header, and Kafka does not have a retry queue.
   > 
   > This also vaguely reminds me of the reason why PR #4179 was not merged, as if considering that this method can only be implemented for RocketMQ and is difficult to extend to other MQ. Is that the reason? @xwm1992
   > 
   > 将消息发给MQ的重试队列进行重试,更准确的说是RocketMQ。因为其他主流的MQ并没有像RocketMQ一样的重试队列,比如RabbitMQ的重试队列是普通队列,只是通过消息头的`x-max-retries`属性来控制、Kafka没有重试队列。 这也让我模糊地想起了没有合并PR #4179的原因,好像是考虑这种方式只能针对RocketMQ来实现,难以拓展到其他MQ。是这个原因吗?@xwm1992
   
   Yes, the main point of this pr is to support the expansion of different retry strategies and decouple the storage-dependent retry strategy from eventmesh
   
   ---
   是的,这个pr的主要修改点在于支持扩展不同的重试策略,将依赖存储的重试策略与eventmesh解耦



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391015033


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   Isolation is configured to allowing users to retry using standalone mode when the storage medium is not using standalone.
   
   ---
   
   是的, 配置隔离是为了应对当存储介质不使用standalone时, 也允许用户使用standalone模式重试。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   Isolation is configured to allowing users to retry using standalone mode when the storage medium is not using standalone.
   
   ---
   
   是的, 配置隔离是为了应对当存储介质不使用standalone时, 也允许用户使用standalone模式重试。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387430520


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   This is because the runtime needs to be loaded into a specific middleware SPI implementation, similar to the `build.gradle` file in the runtime module, lines 49 and 40.
   
   ---
   
   这是因为runtime需要加载到具体中间件的SPI实现, 类似的做法在runtime模块中的`build.gradle`文件, 第49,40行也可以见到.



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   This is because the runtime needs to be loaded into a specific middleware SPI implementation, similar to the `build.gradle` file in the runtime module, lines 49 and 40.
   
   ---
   
   这是因为runtime需要加载到具体中间件的SPI实现, 类似的做法在runtime模块中的`build.gradle`文件, 第49,40行也可以见到.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387863893


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is for the RetryContext can be `rePut`, support the `Timeout` object back into the time wheel, so I reserved the imported parameter.
   
   ---
   
   这个是为了在RetryContext当中可以进行rePut操作, 支持把Timeout对象重新放到时间轮里, 所以我预留了该入参.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is for the RetryContext can be `rePut`, support the `Timeout` object back into the time wheel, so I reserved the imported parameter.
   
   ---
   
   这个是为了在RetryContext当中可以进行rePut操作, 支持把Timeout对象重新放到时间轮里, 所以我预留了该入参.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388175983


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   I personally think it's okay to keep it. Other simillar middleware did the same thing.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388863202


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   And because the runtime is generally an independent server, users can only make this switch take effect through a plugin, which is obviously more troublesome.
   
   ---
   
   并且由于runtime一般是一个独立的服务器, 这样用户又只能通过如plugin的方式才能让此开关生效, 显然比较麻烦.



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   And because the runtime is generally an independent server, users can only make this switch take effect through a plugin, which is obviously more troublesome.
   
   ---
   
   并且由于runtime一般是一个独立的服务器, 这样用户又只能通过如plugin的方式才能让此开关生效, 显然比较麻烦.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387776993


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +73,57 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_PROCESSED_EVENT_LIST.contains(event.getId())) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getHandleMessageContext().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(consumerGroupName)
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getHandleMessageContext().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.add(event.getId());
+            } else {
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMsgContext getHandleMessageContext() throws Exception {

Review Comment:
   Why is the `HandleMsgContext` of the http module specifically used for return types in the protocol module? After removing `topic` from `ConsumerGroupConf`, I don't think you should directly refer to the class of the http module for the convenience of obtaining the topic.
   
   怎么在protocol模块中返回类型专门使用了http模块的`HandleMsgContext`?在将`topic`从`ConsumerGroupConf`中移除后,我觉得你不应该为了方便获取topic就直接引用http模块的类。



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > This is because the runtime needs to be loaded into a specific middleware SPI implementation
   
   When using standalone mode, even if `retry.storageEnabled` is configured to true, we can directly use the retry in memory provided by EventMesh without the need to load the specific implementation of SPI. Of course, at this point, a log can be provided to prompt the user that `retry.storageEnabled` does not work because they are using standalone mode.
   
   In addition, when it is not standalone and `retry. storageEnabled` is configured to true, if the specific implementation of SPI cannot be loaded, the user will be prompted by printing a log, and then  we use the retry in memory provided by EventMesh as a backup.
   
   This can achieve more thorough decoupling, wouldn't it be better?
   
   当使用standalone模式时,即使`retry.storageEnabled`配置为true,就可以直接采用EventMesh提供的内存中重试,而不必加载SPI的具体实现。当然这时可以给出日志提示用户因为使用standalone模式,所以`retry.storageEnabled`不起作用。
   另外还可以在非standalone且`retry.storageEnabled`配置为true时,如果加载不到SPI的具体实现,打印日志提示用户以后,就采用EventMesh提供的内存中重试作为一种兜底。
   这样可以做到更彻底的解耦,不是更好吗?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +73,57 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_PROCESSED_EVENT_LIST.contains(event.getId())) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getHandleMessageContext().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(consumerGroupName)
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getHandleMessageContext().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.add(event.getId());
+            } else {
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);
+        }
+    }
+
+    protected HandleMsgContext getHandleMessageContext() throws Exception {

Review Comment:
   Why is the `HandleMsgContext` of the http module specifically used for return types in the protocol module? After removing `topic` from `ConsumerGroupConf`, I don't think you should directly refer to the class of the http module for the convenience of obtaining the topic.
   
   怎么在protocol模块中返回类型专门使用了http模块的`HandleMsgContext`?在将`topic`从`ConsumerGroupConf`中移除后,我觉得你不应该为了方便获取topic就直接引用http模块的类。



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > This is because the runtime needs to be loaded into a specific middleware SPI implementation
   
   When using standalone mode, even if `retry.storageEnabled` is configured to true, we can directly use the retry in memory provided by EventMesh without the need to load the specific implementation of SPI. Of course, at this point, a log can be provided to prompt the user that `retry.storageEnabled` does not work because they are using standalone mode.
   
   In addition, when it is not standalone and `retry. storageEnabled` is configured to true, if the specific implementation of SPI cannot be loaded, the user will be prompted by printing a log, and then  we use the retry in memory provided by EventMesh as a backup.
   
   This can achieve more thorough decoupling, wouldn't it be better?
   
   当使用standalone模式时,即使`retry.storageEnabled`配置为true,就可以直接采用EventMesh提供的内存中重试,而不必加载SPI的具体实现。当然这时可以给出日志提示用户因为使用standalone模式,所以`retry.storageEnabled`不起作用。
   另外还可以在非standalone且`retry.storageEnabled`配置为true时,如果加载不到SPI的具体实现,打印日志提示用户以后,就采用EventMesh提供的内存中重试作为一种兜底。
   这样可以做到更彻底的解耦,不是更好吗?



##########
eventmesh-retry/build.gradle:
##########
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Review Comment:
   Is it necessary to add this empty file in the new submission?
   
   在新的提交中,有必要增加这个空的文件吗?



##########
eventmesh-retry/build.gradle:
##########
@@ -0,0 +1,16 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */

Review Comment:
   Is it necessary to add this empty file in the new submission?
   
   在新的提交中,有必要增加这个空的文件吗?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391961519


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   In this submission, the author changed the writing of the retry configuration from `retry.storageEnabled=false` to `retry.plugin.type=standalone(default)`. The idea is very good, which separates the configuration of the retry plugin and the storage plugin. However, as far as the current code is concerned, new issues may arise. For example, if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=rabbitmq`, but the retry plugin is actually connected to the address of rabbitmq (retry will also fail), or if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=standalone`, the retry plugin is actually 'connected' to memory (retry will also fail). So this actually makes `retry.plugin.type=standalone(default)` not as good as previous `retry.storageEnabled=false`.
   
   作者在该提交中,将retry配置的写法从`retry.storageEnabled=false`改成了`retry.plugin.type=standalone(default)`。思路是很好的,这样将retry插件和storage插件的配置隔离开。但是就目前的代码而言会出现新的问题。比如用户的配置是`retry.plugin.type=rocketmq`和`storage.plugin.type=rabbitmq`,但其实retry插件连接是rabbitmq的地址(重试也将失效),或者用户配置的是`retry.plugin.type=rocketmq`和`storage.plugin.type=standalone`,其实retry插件“连接”的是内存(重试也将失效)。所以这反而使得`retry.plugin.type=standalone(default)`没有之前`retry.storageEnabled=false`好。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   In this submission, the author changed the writing of the retry configuration from `retry.storageEnabled=false` to `retry.plugin.type=standalone(default)`. The idea is very good, which separates the configuration of the retry plugin and the storage plugin. However, as far as the current code is concerned, new issues may arise. For example, if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=rabbitmq`, but the retry plugin is actually connected to the address of rabbitmq (retry will also fail), or if the user's configuration is `retry.plugin.type=rocketmq` and `storage.plugin.type=standalone`, the retry plugin is actually 'connected' to memory (retry will also fail). So this actually makes `retry.plugin.type=standalone(default)` not as good as previous `retry.storageEnabled=false`.
   
   作者在该提交中,将retry配置的写法从`retry.storageEnabled=false`改成了`retry.plugin.type=standalone(default)`。思路是很好的,这样将retry插件和storage插件的配置隔离开。但是就目前的代码而言会出现新的问题。比如用户的配置是`retry.plugin.type=rocketmq`和`storage.plugin.type=rabbitmq`,但其实retry插件连接是rabbitmq的地址(重试也将失效),或者用户配置的是`retry.plugin.type=rocketmq`和`storage.plugin.type=standalone`,其实retry插件“连接”的是内存(重试也将失效)。所以这反而使得`retry.plugin.type=standalone(default)`没有之前`retry.storageEnabled=false`好。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388117190


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的`Timeout`是不是可以删掉了?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386387369


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +76,87 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled = commonConfiguration.isEventMeshServerRetryStorageEnabled();
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                sendMessageBack(event);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                getHandleMessageContext().finish();

Review Comment:
   Based on your code, there is no need to use Map<String, Integer>to increase logical complexity. Because the Integer of this Map only stores 0 and 1, using Set is sufficient. If not in the Set set, add it and follow the retry logic. If there is one in the Set, it is directly processed as successful consumption.
   
   根据你的代码,没必要用Map<String, Integer>增加逻辑复杂性。因为该Map的Integer只存0和1,所以用Set就够了。Set集合中没有则添加进去,然后走重试逻辑;集合中有,直接处理为消费成功。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387425591


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   The semantics of this API is to specify the retry behavior of the Retryable class. I think for the retry class, there is no need to perceive whether the upper layer is retrying in memory or based on storage.
   
   ---
   
   这个api的语义是指定Retryable类的重试行为, 我认为对于重试类而言, 不需要感知上层到底是通过内存重试还是基于存储的重试.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   The semantics of this API is to specify the retry behavior of the Retryable class. I think for the retry class, there is no need to perceive whether the upper layer is retrying in memory or based on storage.
   
   ---
   
   这个api的语义是指定Retryable类的重试行为, 我认为对于重试类而言, 不需要感知上层到底是通过内存重试还是基于存储的重试.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387426482


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   In addition, I set the run method to final, which is invisible to its subclasses.
   
   ---
   
   另外, run方法我设置为了final, 这样对于其子类是不可见的.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/RetryContext.java:
##########
@@ -52,8 +72,62 @@ protected void rePut(Timeout timeout, long tick, TimeUnit timeUnit) {
         timer.newTimeout(timeout.task(), tick, timeUnit);
     }
 
+    public void setEvent(CloudEvent event) {
+        this.event = event;
+    }
+
     @Override
     public void setExecuteTimeHook(long executeTime) {
         this.executeTime = executeTime;
     }
+
+    @Override
+    public final void run(Timeout timeout) throws Exception {
+        boolean eventMeshServerRetryStorageEnabled =
+            Optional.ofNullable(commonConfiguration).map(CommonConfiguration::isEventMeshServerRetryStorageEnabled)
+                .orElse(false);
+        if (eventMeshServerRetryStorageEnabled) {
+            if (!STORAGE_RETRY_TIMES_MAP.containsKey(event.getId())) {
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), 0);
+            }
+            Integer maxTimesPerEvent = STORAGE_RETRY_TIMES_MAP.get(event.getId());
+            if (maxTimesPerEvent < 1) {
+                StorageRetryStrategy storageRetryStrategy = EventMeshExtensionFactory.getExtension(RetryStrategy.class,
+                    commonConfiguration.getEventMeshStoragePluginType()).getStorageRetryStrategy();
+                String consumerGroupName = getConsumerGroupConf().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(getConsumerGroupConf().getConsumerGroup())
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getConsumerGroupConf().getTopic())
+                    .build();
+                storageRetryStrategy.retry(retryConfiguration);
+                STORAGE_RETRY_TIMES_MAP.put(event.getId(), STORAGE_RETRY_TIMES_MAP.get(event.getId()) + 1);
+            } else {
+                STORAGE_RETRY_TIMES_MAP.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            doRun(timeout);

Review Comment:
   In addition, I set the run method to final, which is invisible to its subclasses.
   
   ---
   
   另外, run方法我设置为了final, 这样对于其子类是不可见的.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387813255


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > This is because the runtime needs to be loaded into a specific middleware SPI implementation
   
   When using standalone mode, even if `retry.storageEnabled` is configured to true, we can directly use the retry in memory provided by EventMesh without the need to load the specific implementation of SPI. Of course, at this point, a log can be provided to prompt the user that `retry.storageEnabled` does not work because they are using standalone mode.
   
   In addition, when it is not standalone and `retry. storageEnabled` is configured to true, if the specific implementation of SPI cannot be loaded, the user will be prompted by printing a log, and then  we use the retry in memory provided by EventMesh as a backup.
   
   This can achieve more thorough decoupling, wouldn't it be better?
   
   当使用standalone模式时,即使`retry.storageEnabled`配置为true,就可以直接采用EventMesh提供的内存中重试,而不必加载SPI的具体实现。当然这时可以给出日志提示用户因为使用standalone模式,所以`retry.storageEnabled`不起作用。
   另外还可以在非standalone且`retry.storageEnabled`配置为true时,如果加载不到SPI的具体实现,打印日志提示用户以后,就采用EventMesh提供的内存中重试作为一种兜底。
   这样可以做到更彻底的解耦,不是更好吗?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1387855843


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is my question. I saw multiple instances of such code where the passed in timeout was not used. So is this indicating that your previous refactoring of retry in memory using `HashedWheelTimer` was incomplete before, or is it due to inheritance system design?
   
   这是我的一个疑问。看到多处这样的代码,没有使用传入的Timeout。所以这是表示你之前用`HashedWheelTimer`对内存中重试的重构不完全,还是继承体系设计的原因?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   This is my question. I saw multiple instances of such code where the passed in timeout was not used. So is this indicating that your previous refactoring of retry in memory using `HashedWheelTimer` was incomplete before, or is it due to inheritance system design?
   
   这是我的一个疑问。看到多处这样的代码,没有使用传入的Timeout。所以这是表示你之前用`HashedWheelTimer`对内存中重试的重构不完全,还是继承体系设计的原因?



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388789158


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   
   我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388863202


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   And because the runtime is generally an independent server, users can only make this switch take effect through a plugin, which is obviously more troublesome.
   
   ---
   
   并且由于runtime一般是一个独立的服务器, 这样用户又只能通过如plugin的方式才能让此开关生效, 显然比较麻烦.



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   In fact, if the runtime does not show the addition of dependencies, it means that users need to load the dependencies of this SPI implementation by themselves. I am worried that it will create a greater burden for users.
   
   ---
   
   其实如果runtime不显示加入依赖, 就代表了用户需要自行去加载这个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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1386414001


##########
eventmesh-storage-plugin/eventmesh-storage-api/src/main/java/org/apache/eventmesh/api/TopicNameHelper.java:
##########
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.eventmesh.api;
+
+import org.apache.eventmesh.spi.EventMeshExtensionType;
+import org.apache.eventmesh.spi.EventMeshSPI;
+
+import lombok.SneakyThrows;
+
+/**
+ * Topic name generator.
+ */
+@EventMeshSPI(isSingleton = false, eventMeshExtensionType = EventMeshExtensionType.STORAGE)
+public interface TopicNameHelper {
+
+    @SneakyThrows
+    default String generateRetryTopicName(String topicName) {
+        throw new IllegalAccessException("Method not supported.");
+    }

Review Comment:
   This method is no longer used in your new submission.
   
   新的提交中已经不需要该方法了。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388175983


##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   I personally think it's okay to keep it. Other middleware does the same.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388859877


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   > I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   > 
   > 我真诚地觉得还是需要有另一位reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢您及时的回应。
   
   In fact, if the runtime does not show the addition of dependencies, it means that users need to load the dependencies of this SPI implementation by themselves. I am worried that it will create a greater burden for users.
   
   ---
   
   其实如果runtime不显示加入依赖, 就代表了用户需要自行去加载这个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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388789158


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   
   我真诚地觉得还是需要有另一个reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢你及时的回应。



##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   I sincerely believe that there is still a need for another reviewer to express their views on this. @xwm1992. Because perhaps I misunderstood something. Thank you for your timely response.
   
   我真诚地觉得还是需要有另一个reviewer来就此说一下看法,@xwm1992 ,因为也许是我哪里理解得不对。感谢你及时的回应。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388068099


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   You can remove this dependency now.



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的Timeout是不是可以删掉了?



##########
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.");

Review Comment:
   Perhaps "Because eventmesh storage is standalone, 'retry. storageEnable' will be ignored" would be better, because it is not determined whether `retry. storageEnable` is true here.
   
   也许“Because eventmesh storage is standalone, 'retry.storageEnable' will be ignored.”这样表述更好一些,因为这里并没判断`retry.storageEnable`是否为true。



##########
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` as the SPI interface?
   
   这个SPI的设计,是不是可以省去`RetryStrategy`接口,直接用`StorageRetryStrategy`作为SPI接口?



##########
eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/grpc/push/AbstractPushRequest.java:
##########
@@ -158,7 +158,7 @@ protected void removeWaitingMap(WebhookPushRequest request) {
     }
 
     @Override
-    public void run(Timeout timeout) throws Exception {
+    public void doRun(Timeout timeout) throws Exception {
         tryPushRequest();
     }

Review Comment:
   Could `Timeout` in the `doRun (timeout)`<-- `run (timeout)` reserved for `reput()` be removed ?
   
   那为`rePut()`预留的`doRun(Timeout)`  <-- `run(Timeout)`中的Timeout是不是可以删掉了?



##########
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.");

Review Comment:
   Perhaps "Because eventmesh storage is standalone, 'retry. storageEnable' will be ignored" would be better, because it is not determined whether `retry. storageEnable` is true here.
   
   也许“Because eventmesh storage is standalone, 'retry.storageEnable' will be ignored.”这样表述更好一些,因为这里并没判断`retry.storageEnable`是否为true。



##########
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());
+            if (!storageRetryStrategy.isPresent()) {
+                log.warn("Storage retry SPI not found, retry in memory.");
+                doRun(timeout);
+                return;
+            }
+            if (!STORAGE_RETRY_PROCESSED_EVENT_LIST.contains(event.getId())) {
+                String consumerGroupName = getHandleMessageContext().getConsumerGroup();
+                EventMeshProducer producer = getProducerManager().getEventMeshProducer(consumerGroupName);
+                RetryConfiguration retryConfiguration = RetryConfiguration.builder()
+                    .event(event)
+                    .retryStorageEnabled(eventMeshServerRetryStorageEnabled)
+                    .consumerGroupName(consumerGroupName)
+                    .producer(producer.getMqProducerWrapper().getMeshMQProducer())
+                    .topic(getHandleMessageContext().getTopic())
+                    .build();
+                storageRetryStrategy.get().retry(retryConfiguration);
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.add(event.getId());
+            } else {
+                STORAGE_RETRY_PROCESSED_EVENT_LIST.remove(event.getId());
+                getHandleMessageContext().finish();
+            }
+        } else {
+            log.warn("Storage retry disabled, retry in memory.");

Review Comment:
   `log.info` is better. Because this logical branch comes from `retry.storageEnable=false`.



##########
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` 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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] Provide MQ-storage-based retry strategy in http protocol. (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1388814193


##########
eventmesh-runtime/build.gradle:
##########
@@ -72,6 +72,9 @@ dependencies {
     implementation project(":eventmesh-webhook:eventmesh-webhook-api")
     implementation project(":eventmesh-webhook:eventmesh-webhook-receive")
 
+    implementation project(":eventmesh-retry:eventmesh-retry-api")
+    implementation project(":eventmesh-retry:eventmesh-retry-rocketmq")

Review Comment:
   The core question may be whether the user needs to declare the retry-rocketmq dependency.



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "yanrongzhen (via GitHub)" <gi...@apache.org>.
yanrongzhen commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1392099295


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   The judgment of whether it matches needs to determine whether the strings of the two plug-in types are equal, which may lead to the coupling of the configuration.
   
   ---
   
   是否匹配的判断需要判断两者插件类型的字符串是否相等, 感觉可能会导致配置的耦合。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   The judgment of whether it matches needs to determine whether the strings of the two plug-in types are equal, which may lead to the coupling of the configuration.
   
   ---
   
   是否匹配的判断需要判断两者插件类型的字符串是否相等, 感觉可能会导致配置的耦合。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1392240839


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   > or coupling judgment processing must be carried out in the code. The judgment conditions are: if the retry strategy is used or the corresponding The storage module is the same, or it is the default strategy.
   
   Since that's the case, I prefer the above treatment. Otherwise, if the two configurations do not match, the retry strategy may only fail without reporting an error or providing corresponding prompts. At this point, it is difficult for users to detect, as they assume that the retry strategy is running normally according to their own configuration `retry.plugin.type`.
   
   既然如此,我倾向于上述这种处理。否则的话,当两者配置不匹配时,重试策略可能只是失效,而不报错或者给出相应的提示。这时用户是很难察觉的,会以为重试策略在按照自己的配置`retry.plugin.type`正常运行。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   > or coupling judgment processing must be carried out in the code. The judgment conditions are: if the retry strategy is used or the corresponding The storage module is the same, or it is the default strategy.
   
   Since that's the case, I prefer the above treatment. Otherwise, if the two configurations do not match, the retry strategy may only fail without reporting an error or providing corresponding prompts. At this point, it is difficult for users to detect, as they assume that the retry strategy is running normally according to their own configuration `retry.plugin.type`.
   
   既然如此,我倾向于上述这种处理。否则的话,当两者配置不匹配时,重试策略可能只是失效,而不报错或者给出相应的提示。这时用户是很难察觉的,会以为重试策略在按照自己的配置`retry.plugin.type`正常运行。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org


Re: [PR] [ISSUE#4178] When there are a large number of errors in the HTTP target, RocketMQ consumption is slow (eventmesh)

Posted by "pandaapo (via GitHub)" <gi...@apache.org>.
pandaapo commented on code in PR #4544:
URL: https://github.com/apache/eventmesh/pull/4544#discussion_r1391041366


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   If it only serves the purpose of "allowing users to retry using standalone mode when the storage medium is not using standalone", then the significance of this modification is not significant, as the previous `server. retry. storageEnabled=false` can also achieve this.
   
   What I want to express is that the modifications you made to isolate are not thorough enough, because when the retry plugin is non standalone, the storage medium on which the retry strategy depends still uses the configuration of the storage plugin's storage medium, which will bring new problems. For example, the user has configured `retry. plugin. type=rocketmq`, `storage. plugin. type=rabbitmq`, but the middleware configuration used for the former is still the latter.
   
   如果只起到“当存储介质不使用standalone时, 也允许用户使用standalone模式重试”这一个作用的话,那这个修改意义就不大了,因为之前的`server.retry.storageEnabled=false`也能做到。
   我想表达的是你为了隔离做的这些修改,不够彻底,因为当retry plugin是非standalone时,重试策略依赖的存储介质仍然使用Storage插件的存储介质的配置,这就会带来新的问题。比如用户配置`retry.plugin.type=rocketmq`,`storage.plugin.type=rabbitmq`,但是前者用的中间件配置还是后者的。



##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/config/CommonConfiguration.java:
##########
@@ -111,8 +112,8 @@ public class CommonConfiguration {
     @ConfigFiled(reload = true)
     private String meshGroup;
 
-    @ConfigFiled(field = "server.retry.storageEnabled")
-    private boolean eventMeshServerRetryStorageEnabled = Boolean.FALSE;
+    @ConfigFiled(field = "server.retry.plugin.type")
+    private String eventMeshRetryPluginType = Constants.STANDALONE;

Review Comment:
   If it only serves the purpose of "allowing users to retry using standalone mode when the storage medium is not using standalone", then the significance of this modification is not significant, as the previous `server. retry. storageEnabled=false` can also achieve this.
   
   What I want to express is that the modifications you made to isolate are not thorough enough, because when the retry plugin is non standalone, the storage medium on which the retry strategy depends still uses the configuration of the storage plugin's storage medium, which will bring new problems. For example, the user has configured `retry. plugin. type=rocketmq`, `storage. plugin. type=rabbitmq`, but the middleware configuration used for the former is still the latter.
   
   如果只起到“当存储介质不使用standalone时, 也允许用户使用standalone模式重试”这一个作用的话,那这个修改意义就不大了,因为之前的`server.retry.storageEnabled=false`也能做到。
   我想表达的是你为了隔离做的这些修改,不够彻底,因为当retry plugin是非standalone时,重试策略依赖的存储介质仍然使用Storage插件的存储介质的配置,这就会带来新的问题。比如用户配置`retry.plugin.type=rocketmq`,`storage.plugin.type=rabbitmq`,但是前者用的中间件配置还是后者的。



-- 
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: issues-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: issues-help@eventmesh.apache.org