-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Java) Rename mongo non transactional api + implement part 1 of trans…
…actional event store
- Loading branch information
1 parent
1e66ac6
commit 8392907
Showing
13 changed files
with
146 additions
and
36 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...card-enrollment/backend-java/src/main/java/cloud/ambar/common/commandhandler/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cloud.ambar.common.commandhandler; | ||
|
||
abstract public class Command { | ||
} |
37 changes: 37 additions & 0 deletions
37
...lment/backend-java/src/main/java/cloud/ambar/common/commandhandler/CommandController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cloud.ambar.common.commandhandler; | ||
|
||
import cloud.ambar.common.eventstore.EventStore; | ||
import lombok.RequiredArgsConstructor; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import java.util.Arrays; | ||
import java.util.stream.Collectors; | ||
|
||
@RequiredArgsConstructor | ||
public class CommandController { | ||
private final EventStore eventStore; | ||
private static final Logger log = LogManager.getLogger(CommandController.class); | ||
|
||
public void processCommand(final Command command, final CommandHandler commandHandler) { | ||
try { | ||
eventStore.beginTransaction(); | ||
commandHandler.handleCommand(command); | ||
eventStore.commitTransaction(); | ||
} catch (Exception e) { | ||
log.error("Failed to process reaction command."); | ||
log.error(e); | ||
log.error(e.getMessage()); | ||
|
||
String stackTraceString = Arrays.stream(e.getStackTrace()) | ||
.map(StackTraceElement::toString) | ||
.collect(Collectors.joining("\n")); | ||
log.error(stackTraceString); | ||
|
||
if (eventStore.isTransactionActive()) { | ||
eventStore.abortTransaction(); | ||
eventStore.closeSession(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
...rollment/backend-java/src/main/java/cloud/ambar/common/sessionauth/SessionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
.../main/java/cloud/ambar/creditcard/enrollment/commandhandler/RequestEnrollmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters