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: [email protected]

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


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

Reply via email to