Fix deprecation for TX; fix JMS tests; Moore-SR6

* Upgrade to Spring Data Moore-SR6
* Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder`
for deprecations in the `TransactionInterceptor`
* Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder`
consumers to expose new `TransactionManager`-based options and
deprecate `PlatformTransactionManager`-based
* Fix failing JMS tests to reuse an ActiveMQ Connection Factory with a
`trustedPackaged(*)`

**Cherry-pick to master**
This commit is contained in:
Artem Bilan
2020-03-25 12:51:00 -04:00
parent 9dc55fd8e4
commit 98765fe9f8
29 changed files with 334 additions and 332 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.
@@ -32,6 +32,7 @@ import org.springframework.integration.transaction.TransactionInterceptorBuilder
import org.springframework.messaging.MessageHandler;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.util.Assert;
@@ -114,8 +115,23 @@ public abstract class ConsumerEndpointSpec<S extends ConsumerEndpointSpec<S, H>,
* for the {@link MessageHandler}.
* @param transactionManager the {@link PlatformTransactionManager} to use.
* @return the spec.
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager)}
*/
@Deprecated
public S transactional(PlatformTransactionManager transactionManager) {
return transactional((TransactionManager) transactionManager);
}
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
* {@code PlatformTransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@link MessageHandler}.
* @param transactionManager the {@link TransactionManager} to use.
* @return the spec.
* @since 5.2.5
*/
public S transactional(TransactionManager transactionManager) {
return transactional(transactionManager, false);
}
@@ -130,8 +146,27 @@ public abstract class ConsumerEndpointSpec<S extends ConsumerEndpointSpec<S, H>,
* {@link org.springframework.integration.transaction.TransactionHandleMessageAdvice}
* extension.
* @return the spec.
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager, boolean)}
*/
@Deprecated
public S transactional(PlatformTransactionManager transactionManager, boolean handleMessageAdvice) {
return transactional((TransactionManager) transactionManager, handleMessageAdvice);
}
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
* {@code PlatformTransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@link MessageHandler}.
* @param transactionManager the {@link TransactionManager} to use.
* @param handleMessageAdvice the flag to indicate the target {@link Advice} type:
* {@code false} - regular {@link TransactionInterceptor}; {@code true} -
* {@link org.springframework.integration.transaction.TransactionHandleMessageAdvice}
* extension.
* @return the spec.
* @since 5.2.5
*/
public S transactional(TransactionManager transactionManager, boolean handleMessageAdvice) {
return transactional(new TransactionInterceptorBuilder(handleMessageAdvice)
.transactionManager(transactionManager)
.build());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.
@@ -31,6 +31,7 @@ import org.springframework.integration.transaction.TransactionInterceptorBuilder
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.util.Assert;
@@ -193,14 +194,29 @@ public final class DelayerEndpointSpec extends ConsumerEndpointSpec<DelayerEndpo
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
* {@code PlatformTransactionManager} and default
* {@link PlatformTransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@link org.springframework.messaging.MessageHandler}.
* @param transactionManager the {@link PlatformTransactionManager} to use.
* @return the spec.
* @since 5.0.8
* @deprecated since 5.2.5 in favor of {@link #transactionalRelease(TransactionManager)}
*/
@Deprecated
public DelayerEndpointSpec transactionalRelease(PlatformTransactionManager transactionManager) {
return transactionalRelease((TransactionManager) transactionManager);
}
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
* {@link TransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@link org.springframework.messaging.MessageHandler}.
* @param transactionManager the {@link TransactionManager} to use.
* @return the spec.
* @since 5.2.5
*/
public DelayerEndpointSpec transactionalRelease(TransactionManager transactionManager) {
return transactionalRelease(
new TransactionInterceptorBuilder()
.transactionManager(transactionManager)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.
@@ -32,6 +32,7 @@ import org.springframework.integration.transaction.TransactionSynchronizationFac
import org.springframework.messaging.MessageChannel;
import org.springframework.scheduling.Trigger;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.interceptor.TransactionInterceptor;
import org.springframework.util.ErrorHandler;
@@ -144,13 +145,28 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the
* provided {@code PlatformTransactionManager} and default
* provided {@link PlatformTransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@code pollingTask}.
* @param transactionManager the {@link PlatformTransactionManager} to use.
* @return the spec.
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager)}
*/
@Deprecated
public PollerSpec transactional(PlatformTransactionManager transactionManager) {
return transactional((TransactionManager) transactionManager);
}
/**
* Specify a {@link TransactionInterceptor} {@link Advice} with the
* provided {@link TransactionManager} and default
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
* for the {@code pollingTask}.
* @param transactionManager the {@link TransactionManager} to use.
* @return the spec.
* @since 5.2.5
*/
public PollerSpec transactional(TransactionManager transactionManager) {
return transactional(new TransactionInterceptorBuilder()
.transactionManager(transactionManager)
.build());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.
@@ -20,6 +20,7 @@ import java.util.Properties;
import org.springframework.integration.handler.advice.HandleMessageAdvice;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.interceptor.TransactionAttributeSource;
import org.springframework.transaction.interceptor.TransactionInterceptor;
@@ -46,12 +47,42 @@ public class TransactionHandleMessageAdvice extends TransactionInterceptor imple
public TransactionHandleMessageAdvice() {
}
public TransactionHandleMessageAdvice(PlatformTransactionManager ptm, Properties attributes) {
super(ptm, attributes);
/**
* Create a new TransactionHandleMessageAdvice.
* @param transactionManager the default transaction manager to perform the actual transaction management
* @param transactionAttributeSource the attribute source to be used to find transaction attributes
* @since 5.2.5
* @see TransactionInterceptor
*/
public TransactionHandleMessageAdvice(TransactionManager transactionManager,
TransactionAttributeSource transactionAttributeSource) {
super(transactionManager, transactionAttributeSource);
}
/**
* Create a new TransactionHandleMessageAdvice.
* @param ptm the default transaction manager to perform the actual transaction management
* @param attributes the attribute source to be used to find transaction attributes
* @deprecated since 5.2.5 in favor of {@link #TransactionHandleMessageAdvice()}
* and {@link #setTransactionManager(TransactionManager)}, {@link #setTransactionAttributes(Properties)}
*/
@Deprecated
public TransactionHandleMessageAdvice(PlatformTransactionManager ptm, Properties attributes) {
setTransactionManager(ptm);
setTransactionAttributes(attributes);
}
/**
* Create a new TransactionHandleMessageAdvice.
* @param ptm the default transaction manager to perform the actual transaction management
* @param tas the attribute source to be used to find transaction attributes
* @deprecated since 5.2.5 in favor of
* {@link #TransactionHandleMessageAdvice(TransactionManager, TransactionAttributeSource)}
*/
@Deprecated
public TransactionHandleMessageAdvice(PlatformTransactionManager ptm, TransactionAttributeSource tas) {
super(ptm, tas);
this((TransactionManager) ptm, tas);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.
@@ -17,6 +17,7 @@
package org.springframework.integration.transaction;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
@@ -91,11 +92,27 @@ public class TransactionInterceptorBuilder {
return this;
}
public TransactionInterceptorBuilder transactionManager(PlatformTransactionManager transactionManager) {
/**
* Provide a {@link TransactionManager} instance to use.
* @param transactionManager the {@link TransactionManager} to use
* @return the builder
*/
public TransactionInterceptorBuilder transactionManager(TransactionManager transactionManager) {
this.transactionInterceptor.setTransactionManager(transactionManager);
return this;
}
/**
* Provide a {@link PlatformTransactionManager} instance to use.
* @param transactionManager the {@link PlatformTransactionManager} to use
* @return the builder
* @deprecated since 5.2.5 in favor of {@link #transactionManager(TransactionManager)}
*/
@Deprecated
public TransactionInterceptorBuilder transactionManager(PlatformTransactionManager transactionManager) {
return transactionManager((TransactionManager) transactionManager);
}
public TransactionInterceptor build() {
return this.transactionInterceptor;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.interceptor.TransactionAttribute;
@@ -75,7 +76,7 @@ public class TransactionInterceptorBuilderTests {
}
@Bean
public TransactionInterceptor interceptor1(PlatformTransactionManager transactionManager) {
public TransactionInterceptor interceptor1(TransactionManager transactionManager) {
return new TransactionInterceptorBuilder()
.propagation(Propagation.REQUIRES_NEW)
.isolation(Isolation.SERIALIZABLE)