FINERACT-1724 - Transaction handling fix
- [x] Fix Fetch new transaction
This commit is contained in:
-6
@@ -89,17 +89,11 @@ public class CommandSourceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
|
|
||||||
public CommandSource findCommandSource(CommandWrapper wrapper, String idempotencyKey) {
|
public CommandSource findCommandSource(CommandWrapper wrapper, String idempotencyKey) {
|
||||||
return commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(), wrapper.entityName(),
|
return commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(), wrapper.entityName(),
|
||||||
idempotencyKey);
|
idempotencyKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandSource findCommandSourceNoTransaction(CommandWrapper wrapper, String idempotencyKey) {
|
|
||||||
return commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(), wrapper.entityName(),
|
|
||||||
idempotencyKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandSource getInitialCommandSource(CommandWrapper wrapper, JsonCommand jsonCommand, AppUser maker, String idempotencyKey) {
|
private CommandSource getInitialCommandSource(CommandWrapper wrapper, JsonCommand jsonCommand, AppUser maker, String idempotencyKey) {
|
||||||
CommandSource commandSourceResult;
|
CommandSource commandSourceResult;
|
||||||
if (jsonCommand.commandId() != null) {
|
if (jsonCommand.commandId() != null) {
|
||||||
|
|||||||
+2
-12
@@ -109,22 +109,12 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
try {
|
try {
|
||||||
result = findCommandHandler(wrapper).processCommand(command);
|
result = findCommandHandler(wrapper).processCommand(command);
|
||||||
} catch (Throwable t) { // NOSONAR
|
} catch (Throwable t) { // NOSONAR
|
||||||
CommandSource source;
|
CommandSource source = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||||
if (BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
|
|
||||||
source = commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
|
|
||||||
} else {
|
|
||||||
source = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
|
||||||
}
|
|
||||||
commandSourceService.saveFailed(source);
|
commandSourceService.saveFailed(source);
|
||||||
publishHookErrorEvent(wrapper, command, t);
|
publishHookErrorEvent(wrapper, command, t);
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
CommandSource initialCommandSource;
|
CommandSource initialCommandSource = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||||
if (BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
|
|
||||||
initialCommandSource = commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
|
|
||||||
} else {
|
|
||||||
initialCommandSource = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
initialCommandSource.setResult(toApiJsonSerializer.serializeResult(result));
|
initialCommandSource.setResult(toApiJsonSerializer.serializeResult(result));
|
||||||
initialCommandSource.updateResourceId(result.getResourceId());
|
initialCommandSource.updateResourceId(result.getResourceId());
|
||||||
|
|||||||
Reference in New Issue
Block a user