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) {
|
||||
return commandSourceRepository.findByActionNameAndEntityNameAndIdempotencyKey(wrapper.actionName(), wrapper.entityName(),
|
||||
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) {
|
||||
CommandSource commandSourceResult;
|
||||
if (jsonCommand.commandId() != null) {
|
||||
|
||||
+2
-12
@@ -109,22 +109,12 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
||||
try {
|
||||
result = findCommandHandler(wrapper).processCommand(command);
|
||||
} catch (Throwable t) { // NOSONAR
|
||||
CommandSource source;
|
||||
if (BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
|
||||
source = commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
|
||||
} else {
|
||||
source = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||
}
|
||||
CommandSource source = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||
commandSourceService.saveFailed(source);
|
||||
publishHookErrorEvent(wrapper, command, t);
|
||||
throw t;
|
||||
}
|
||||
CommandSource initialCommandSource;
|
||||
if (BatchRequestContextHolder.getEnclosingTransaction().isPresent()) {
|
||||
initialCommandSource = commandSourceService.findCommandSourceNoTransaction(wrapper, idempotencyKey);
|
||||
} else {
|
||||
initialCommandSource = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||
}
|
||||
CommandSource initialCommandSource = commandSourceService.findCommandSource(wrapper, idempotencyKey);
|
||||
|
||||
initialCommandSource.setResult(toApiJsonSerializer.serializeResult(result));
|
||||
initialCommandSource.updateResourceId(result.getResourceId());
|
||||
|
||||
Reference in New Issue
Block a user