Added support for specifying a TransactionManager
Before this commit, Spring Cloud Task did not correctly configure the provided PlatformTransactionManager with the TaskRepository. This commit addressis this bug. Resolves #652 Polished PR on Merge
This commit is contained in:
committed by
Glenn Renfro
parent
f7c2501314
commit
00b8acab55
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.scope.ScopedProxyUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.task.repository.TaskExplorer;
|
||||
@@ -89,8 +88,7 @@ public class SimpleTaskAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PlatformTransactionManager transactionManager() {
|
||||
public PlatformTransactionManager springCloudTaskTransactionManager() {
|
||||
return this.platformTransactionManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
* information.
|
||||
*
|
||||
* @author Glenn Renfro
|
||||
* @author Michael Minella
|
||||
*/
|
||||
public interface TaskRepository {
|
||||
|
||||
@@ -37,7 +38,7 @@ public interface TaskRepository {
|
||||
* @param exitMessage to be stored for the task.
|
||||
* @return the updated {@link TaskExecution}
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime,
|
||||
String exitMessage);
|
||||
|
||||
@@ -51,7 +52,7 @@ public interface TaskRepository {
|
||||
* @return the updated {@link TaskExecution}
|
||||
* @since 1.1.0
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution completeTaskExecution(long executionId, Integer exitCode, Date endTime,
|
||||
String exitMessage, String errorMessage);
|
||||
|
||||
@@ -64,7 +65,7 @@ public interface TaskRepository {
|
||||
* TaskExecution's taskExecutionId will also contain the id that was used to store the
|
||||
* TaskExecution.
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution createTaskExecution(TaskExecution taskExecution);
|
||||
|
||||
/**
|
||||
@@ -75,7 +76,7 @@ public interface TaskRepository {
|
||||
* @param name task name to be associated with the task execution.
|
||||
* @return the initial {@link TaskExecution}
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution createTaskExecution(String name);
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public interface TaskRepository {
|
||||
* launching, etc).
|
||||
* @return the initial {@link TaskExecution}
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution createTaskExecution();
|
||||
|
||||
/**
|
||||
@@ -97,7 +98,7 @@ public interface TaskRepository {
|
||||
* @param externalExecutionId id assigned to the task by the platform.
|
||||
* @return TaskExecution created based on the parameters.
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, Date startTime,
|
||||
List<String> arguments, String externalExecutionId);
|
||||
|
||||
@@ -106,7 +107,7 @@ public interface TaskRepository {
|
||||
* @param executionid to the task execution to be updated.
|
||||
* @param externalExecutionId id assigned to the task by the platform.
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
void updateExternalExecutionId(long executionid, String externalExecutionId);
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ public interface TaskRepository {
|
||||
* @return A TaskExecution that contains the information available at the beginning of
|
||||
* a TaskExecution.
|
||||
*/
|
||||
@Transactional
|
||||
@Transactional("springCloudTaskTransactionManager")
|
||||
TaskExecution startTaskExecution(long executionid, String taskName, Date startTime,
|
||||
List<String> arguments, String externalExecutionId, Long parentExecutionId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user