vidakovic commented on code in PR #5436:
URL: https://github.com/apache/fineract/pull/5436#discussion_r2765210586
##########
fineract-command/src/main/java/org/apache/fineract/command/implementation/SynchronousCommandExecutor.java:
##########
@@ -18,37 +18,41 @@
*/
package org.apache.fineract.command.implementation;
-import java.util.List;
import java.util.function.Supplier;
-import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.command.core.Command;
-import org.apache.fineract.command.core.CommandExecutor;
+import org.apache.fineract.command.core.CommandAuditor;
import org.apache.fineract.command.core.CommandHandler;
-import org.apache.fineract.command.core.CommandMiddleware;
import org.apache.fineract.command.core.CommandRouter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
@Slf4j
-@RequiredArgsConstructor
@Component
@ConditionalOnProperty(value = "fineract.command.executor", havingValue =
"sync")
@SuppressWarnings({ "unchecked" })
-public class SynchronousCommandExecutor implements CommandExecutor {
+public class SynchronousCommandExecutor extends BaseCommandExecutor {
- private final List<CommandMiddleware> middlewares;
-
- private final CommandRouter router;
+ public SynchronousCommandExecutor(CommandRouter router, CommandAuditor
auditor) {
+ super(router, auditor);
+ }
@Override
- public <REQ, RES> Supplier<RES> execute(Command<REQ> command) {
- for (CommandMiddleware middleware : middlewares) {
- middleware.invoke(command);
- }
-
+ public <REQ, RES> Supplier<RES> execute(final Command<REQ> command) {
CommandHandler<REQ, RES> handler = router.route(command);
- return () -> handler.handle(command);
+ return () -> {
Review Comment:
As we spoke have adapted that now to be closer to the current implementation.
- first write command with status UNDER_PROCESSING
- then on successful execution update the status of the command to PROCESSED
and add the execution result
- on error add error message with ERROR status
All these have now 2 additional levels of fallbacks:
- if access to the database doesn't work then the auditor component tries to
dump the commands as json files to the disk
- if that doesn't for some reason or the file dead-letter queue is disabled
(by default it is) then the command and the error message are logged to the
system log (most likely something like cloudwatch etc.)
--
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]