Fix new classes and packages tangles (#3898)
* Fix new classes and packages tangles * Move `MessagingAnnotationPostProcessor` and `MethodAnnotationPostProcessor` impls out of the `config.annotation` package due to usage of the `FactoryBean` configs * Move `GenericHandler` and `GenericTransformer` to the `core` package to break a tangle with a `LambdaMessageProcessor` * Clean up affected tests and docs * * Fix Checkstyle violation for imports order
This commit is contained in:
@@ -39,14 +39,15 @@ import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.aggregator.MessageGroupProcessor;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.context.IntegrationProperties;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.gateway.MethodArgsHolder;
|
||||
import org.springframework.integration.gateway.RequestReplyExchanger;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.DelayHandler;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.json.JsonPathUtils;
|
||||
import org.springframework.integration.message.AdviceMessage;
|
||||
@@ -56,7 +57,6 @@ import org.springframework.integration.store.MessageHolder;
|
||||
import org.springframework.integration.store.MessageMetadata;
|
||||
import org.springframework.integration.support.MutableMessage;
|
||||
import org.springframework.integration.support.MutableMessageHeaders;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -73,10 +73,7 @@ import org.springframework.integration.annotation.Reactive;
|
||||
import org.springframework.integration.annotation.Role;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessagePublishingErrorHandler;
|
||||
import org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.config.IntegrationConfigUtils;
|
||||
import org.springframework.integration.config.RouterFactoryBean;
|
||||
import org.springframework.integration.config.annotation.MethodAnnotationPostProcessor;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.context.Orderable;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -30,7 +30,6 @@ import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.integration.annotation.BridgeFrom;
|
||||
import org.springframework.integration.annotation.BridgeTo;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.integration.annotation.Filter;
|
||||
import org.springframework.integration.config.FilterFactoryBean;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.filter.MessageFilter;
|
||||
import org.springframework.integration.filter.MethodInvokingSelector;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -31,8 +31,6 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.MergedAnnotations;
|
||||
import org.springframework.integration.annotation.InboundChannelAdapter;
|
||||
import org.springframework.integration.annotation.Poller;
|
||||
import org.springframework.integration.config.IntegrationConfigUtils;
|
||||
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.endpoint.MethodInvokingMessageSource;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
@@ -22,7 +22,6 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -60,6 +60,7 @@ import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.config.annotation.MethodAnnotationPostProcessor;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -33,7 +33,6 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.config.RouterFactoryBean;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.config.ServiceActivatorFactoryBean;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.config.SplitterFactoryBean;
|
||||
import org.springframework.integration.splitter.AbstractMessageSplitter;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.integration.util.MessagingAnnotationUtils;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.config.annotation;
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.integration.config.TransformerFactoryBean;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2022 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.handler;
|
||||
package org.springframework.integration.core;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
* Copyright 2014-2022 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.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.transformer;
|
||||
package org.springframework.integration.core;
|
||||
|
||||
/**
|
||||
* Generic (lambda) strategy interface for transformer.
|
||||
@@ -43,7 +43,9 @@ import org.springframework.integration.channel.interceptor.WireTap;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype;
|
||||
@@ -58,7 +60,6 @@ import org.springframework.integration.handler.BeanNameMessageProcessor;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.integration.handler.DelayHandler;
|
||||
import org.springframework.integration.handler.ExpressionCommandMessageProcessor;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.handler.LambdaMessageProcessor;
|
||||
import org.springframework.integration.handler.LoggingHandler;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
@@ -79,7 +80,6 @@ import org.springframework.integration.support.MapBuilder;
|
||||
import org.springframework.integration.transformer.ClaimCheckInTransformer;
|
||||
import org.springframework.integration.transformer.ClaimCheckOutTransformer;
|
||||
import org.springframework.integration.transformer.ExpressionEvaluatingTransformer;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.integration.transformer.HeaderFilter;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2020 the original author or authors.
|
||||
* Copyright 2016-2022 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.
|
||||
@@ -19,12 +19,12 @@ package org.springframework.integration.dsl;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,8 +32,9 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.core.log.LogMessage;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.transformer;
|
||||
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,12 +60,12 @@ public abstract class ClassUtils {
|
||||
public static final Method SELECTOR_ACCEPT_METHOD;
|
||||
|
||||
/**
|
||||
* The {@code org.springframework.integration.transformer.GenericTransformer#transform(Object)} method object.
|
||||
* The {@code org.springframework.integration.core.GenericTransformer#transform(Object)} method object.
|
||||
*/
|
||||
public static final Method TRANSFORMER_TRANSFORM_METHOD;
|
||||
|
||||
/**
|
||||
* The {@code org.springframework.integration.handler.GenericHandler#handle(Object, Map)} method object.
|
||||
* The {@code org.springframework.integration.core.GenericHandler#handle(Object, Map)} method object.
|
||||
*/
|
||||
public static final Method HANDLER_HANDLE_METHOD;
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class ClassUtils {
|
||||
try {
|
||||
genericTransformerClass =
|
||||
org.springframework.util.ClassUtils.forName(
|
||||
"org.springframework.integration.transformer.GenericTransformer", defaultClassLoader);
|
||||
"org.springframework.integration.core.GenericTransformer", defaultClassLoader);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
ReflectionUtils.rethrowRuntimeException(e);
|
||||
@@ -130,7 +130,7 @@ public abstract class ClassUtils {
|
||||
try {
|
||||
genericHandlerClass =
|
||||
org.springframework.util.ClassUtils.forName(
|
||||
"org.springframework.integration.handler.GenericHandler", defaultClassLoader);
|
||||
"org.springframework.integration.core.GenericHandler", defaultClassLoader);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
ReflectionUtils.rethrowRuntimeException(e);
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.integration.filter.MessageFilter
|
||||
import org.springframework.integration.filter.MethodInvokingSelector
|
||||
import org.springframework.integration.handler.BridgeHandler
|
||||
import org.springframework.integration.handler.DelayHandler
|
||||
import org.springframework.integration.handler.GenericHandler
|
||||
import org.springframework.integration.core.GenericHandler
|
||||
import org.springframework.integration.handler.LoggingHandler
|
||||
import org.springframework.integration.handler.MessageProcessor
|
||||
import org.springframework.integration.handler.MessageTriggerAction
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -21,13 +21,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -42,32 +41,31 @@ public class ServiceActivatorAnnotationPostProcessorTests {
|
||||
@Test
|
||||
public void testAnnotatedMethod() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
TestApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
RootBeanDefinition postProcessorDef = new RootBeanDefinition(MessagingAnnotationPostProcessor.class);
|
||||
context.registerBeanDefinition("postProcessor", postProcessorDef);
|
||||
context.registerBeanDefinition("testChannel", new RootBeanDefinition(DirectChannel.class));
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(SimpleServiceActivatorAnnotationTestBean.class);
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(latch);
|
||||
context.registerBeanDefinition("testBean", beanDefinition);
|
||||
context.refresh();
|
||||
SimpleServiceActivatorAnnotationTestBean testBean =
|
||||
context.getBean("testBean", SimpleServiceActivatorAnnotationTestBean.class);
|
||||
assertThat(latch.getCount()).isEqualTo(1);
|
||||
assertThat(testBean.getMessageText()).isNull();
|
||||
MessageChannel testChannel = (MessageChannel) context.getBean("testChannel");
|
||||
testChannel.send(new GenericMessage<>("test-123"));
|
||||
latch.await(1000, TimeUnit.MILLISECONDS);
|
||||
assertThat(latch.getCount()).isEqualTo(0);
|
||||
assertThat(testBean.getMessageText()).isEqualTo("test-123");
|
||||
context.close();
|
||||
try (TestApplicationContext context = TestUtils.createTestApplicationContext()) {
|
||||
RootBeanDefinition postProcessorDef = new RootBeanDefinition(MessagingAnnotationPostProcessor.class);
|
||||
context.registerBeanDefinition("postProcessor", postProcessorDef);
|
||||
context.registerBeanDefinition("testChannel", new RootBeanDefinition(DirectChannel.class));
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(SimpleServiceActivatorAnnotationTestBean.class);
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(latch);
|
||||
context.registerBeanDefinition("testBean", beanDefinition);
|
||||
context.refresh();
|
||||
SimpleServiceActivatorAnnotationTestBean testBean =
|
||||
context.getBean("testBean", SimpleServiceActivatorAnnotationTestBean.class);
|
||||
assertThat(latch.getCount()).isEqualTo(1);
|
||||
assertThat(testBean.getMessageText()).isNull();
|
||||
MessageChannel testChannel = (MessageChannel) context.getBean("testChannel");
|
||||
testChannel.send(new GenericMessage<>("test-123"));
|
||||
assertThat(latch.await(1000, TimeUnit.MILLISECONDS)).isTrue();
|
||||
assertThat(testBean.getMessageText()).isEqualTo("test-123");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class AbstractServiceActivatorAnnotationTestBean {
|
||||
|
||||
protected String messageText;
|
||||
private final CountDownLatch latch;
|
||||
|
||||
private CountDownLatch latch;
|
||||
protected String messageText;
|
||||
|
||||
public AbstractServiceActivatorAnnotationTestBean(CountDownLatch latch) {
|
||||
this.latch = latch;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
* Copyright 2017-2022 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.
|
||||
@@ -43,7 +43,9 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.log.LogAccessor;
|
||||
import org.springframework.integration.config.AbstractMethodAnnotationPostProcessor;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.expression.FunctionExpression;
|
||||
import org.springframework.integration.handler.LoggingHandler;
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.annotation.Filter;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.test.util.TestUtils.TestApplicationContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 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.
|
||||
@@ -21,7 +21,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
@@ -31,6 +31,7 @@ import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.config.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -45,99 +46,103 @@ public class SubscriberOrderTests {
|
||||
|
||||
@Test
|
||||
public void directChannelAndFailoverDispatcherWithSingleCallPerMethod() {
|
||||
GenericApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
context.registerBeanDefinition("postProcessor", new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
RootBeanDefinition channelDefinition = new RootBeanDefinition(DirectChannel.class);
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(1);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<String>("test-1"));
|
||||
channel.send(new GenericMessage<String>("test-2"));
|
||||
channel.send(new GenericMessage<String>("test-3"));
|
||||
channel.send(new GenericMessage<String>("test-4"));
|
||||
channel.send(new GenericMessage<String>("test-5"));
|
||||
List<Integer> calls = testBean.calls;
|
||||
assertThat(calls.size()).isEqualTo(5);
|
||||
assertThat(calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(calls.get(1).intValue()).isEqualTo(2);
|
||||
assertThat(calls.get(2).intValue()).isEqualTo(3);
|
||||
assertThat(calls.get(3).intValue()).isEqualTo(4);
|
||||
assertThat(calls.get(4).intValue()).isEqualTo(5);
|
||||
context.close();
|
||||
try (GenericApplicationContext context = TestUtils.createTestApplicationContext()) {
|
||||
context.registerBeanDefinition("postProcessor",
|
||||
new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
RootBeanDefinition channelDefinition = new RootBeanDefinition(DirectChannel.class);
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(1);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<>("test-1"));
|
||||
channel.send(new GenericMessage<>("test-2"));
|
||||
channel.send(new GenericMessage<>("test-3"));
|
||||
channel.send(new GenericMessage<>("test-4"));
|
||||
channel.send(new GenericMessage<>("test-5"));
|
||||
List<Integer> calls = testBean.calls;
|
||||
assertThat(calls.size()).isEqualTo(5);
|
||||
assertThat(calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(calls.get(1).intValue()).isEqualTo(2);
|
||||
assertThat(calls.get(2).intValue()).isEqualTo(3);
|
||||
assertThat(calls.get(3).intValue()).isEqualTo(4);
|
||||
assertThat(calls.get(4).intValue()).isEqualTo(5);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void directChannelAndFailoverDispatcherWithMultipleCallsPerMethod() {
|
||||
GenericApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
context.registerBeanDefinition("postProcessor", new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
BeanDefinitionBuilder channelBuilder = BeanDefinitionBuilder.rootBeanDefinition(DirectChannel.class);
|
||||
channelBuilder.addConstructorArgValue(null);
|
||||
RootBeanDefinition channelDefinition = (RootBeanDefinition) channelBuilder.getBeanDefinition();
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(2);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<String>("test-1"));
|
||||
channel.send(new GenericMessage<String>("test-2"));
|
||||
channel.send(new GenericMessage<String>("test-3"));
|
||||
channel.send(new GenericMessage<String>("test-4"));
|
||||
channel.send(new GenericMessage<String>("test-5"));
|
||||
channel.send(new GenericMessage<String>("test-6"));
|
||||
channel.send(new GenericMessage<String>("test-7"));
|
||||
channel.send(new GenericMessage<String>("test-8"));
|
||||
channel.send(new GenericMessage<String>("test-9"));
|
||||
channel.send(new GenericMessage<String>("test-10"));
|
||||
assertThat(testBean.calls.size()).isEqualTo(10);
|
||||
assertThat(testBean.calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(1).intValue()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(2).intValue()).isEqualTo(2);
|
||||
assertThat(testBean.calls.get(3).intValue()).isEqualTo(2);
|
||||
assertThat(testBean.calls.get(4).intValue()).isEqualTo(3);
|
||||
assertThat(testBean.calls.get(5).intValue()).isEqualTo(3);
|
||||
assertThat(testBean.calls.get(6).intValue()).isEqualTo(4);
|
||||
assertThat(testBean.calls.get(7).intValue()).isEqualTo(4);
|
||||
assertThat(testBean.calls.get(8).intValue()).isEqualTo(5);
|
||||
assertThat(testBean.calls.get(9).intValue()).isEqualTo(5);
|
||||
testBean.reset();
|
||||
channel.send(new GenericMessage<String>("test-11"));
|
||||
assertThat(testBean.calls.size()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(0).intValue()).isEqualTo(1);
|
||||
context.close();
|
||||
try (GenericApplicationContext context = TestUtils.createTestApplicationContext()) {
|
||||
context.registerBeanDefinition("postProcessor",
|
||||
new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
BeanDefinitionBuilder channelBuilder = BeanDefinitionBuilder.rootBeanDefinition(DirectChannel.class);
|
||||
channelBuilder.addConstructorArgValue(null);
|
||||
RootBeanDefinition channelDefinition = (RootBeanDefinition) channelBuilder.getBeanDefinition();
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(2);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<>("test-1"));
|
||||
channel.send(new GenericMessage<>("test-2"));
|
||||
channel.send(new GenericMessage<>("test-3"));
|
||||
channel.send(new GenericMessage<>("test-4"));
|
||||
channel.send(new GenericMessage<>("test-5"));
|
||||
channel.send(new GenericMessage<>("test-6"));
|
||||
channel.send(new GenericMessage<>("test-7"));
|
||||
channel.send(new GenericMessage<>("test-8"));
|
||||
channel.send(new GenericMessage<>("test-9"));
|
||||
channel.send(new GenericMessage<>("test-10"));
|
||||
assertThat(testBean.calls.size()).isEqualTo(10);
|
||||
assertThat(testBean.calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(1).intValue()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(2).intValue()).isEqualTo(2);
|
||||
assertThat(testBean.calls.get(3).intValue()).isEqualTo(2);
|
||||
assertThat(testBean.calls.get(4).intValue()).isEqualTo(3);
|
||||
assertThat(testBean.calls.get(5).intValue()).isEqualTo(3);
|
||||
assertThat(testBean.calls.get(6).intValue()).isEqualTo(4);
|
||||
assertThat(testBean.calls.get(7).intValue()).isEqualTo(4);
|
||||
assertThat(testBean.calls.get(8).intValue()).isEqualTo(5);
|
||||
assertThat(testBean.calls.get(9).intValue()).isEqualTo(5);
|
||||
testBean.reset();
|
||||
channel.send(new GenericMessage<>("test-11"));
|
||||
assertThat(testBean.calls.size()).isEqualTo(1);
|
||||
assertThat(testBean.calls.get(0).intValue()).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void directChannelAndRoundRobinDispatcher() {
|
||||
GenericApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
context.registerBeanDefinition("postProcessor", new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
RootBeanDefinition channelDefinition = new RootBeanDefinition(DirectChannel.class);
|
||||
channelDefinition.getConstructorArgumentValues().addGenericArgumentValue(new RoundRobinLoadBalancingStrategy());
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(1000);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<String>("test-1"));
|
||||
channel.send(new GenericMessage<String>("test-2"));
|
||||
channel.send(new GenericMessage<String>("test-3"));
|
||||
channel.send(new GenericMessage<String>("test-4"));
|
||||
channel.send(new GenericMessage<String>("test-5"));
|
||||
List<Integer> calls = testBean.calls;
|
||||
assertThat(calls.size()).isEqualTo(5);
|
||||
assertThat(calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(calls.get(1).intValue()).isEqualTo(2);
|
||||
assertThat(calls.get(2).intValue()).isEqualTo(3);
|
||||
assertThat(calls.get(3).intValue()).isEqualTo(4);
|
||||
assertThat(calls.get(4).intValue()).isEqualTo(5);
|
||||
context.close();
|
||||
try (GenericApplicationContext context = TestUtils.createTestApplicationContext()) {
|
||||
context.registerBeanDefinition("postProcessor",
|
||||
new RootBeanDefinition(MessagingAnnotationPostProcessor.class));
|
||||
RootBeanDefinition channelDefinition = new RootBeanDefinition(DirectChannel.class);
|
||||
channelDefinition.getConstructorArgumentValues()
|
||||
.addGenericArgumentValue(new RoundRobinLoadBalancingStrategy());
|
||||
context.registerBeanDefinition("input", channelDefinition);
|
||||
RootBeanDefinition testBeanDefinition = new RootBeanDefinition(TestBean.class);
|
||||
testBeanDefinition.getConstructorArgumentValues().addGenericArgumentValue(1000);
|
||||
context.registerBeanDefinition("testBean", testBeanDefinition);
|
||||
context.refresh();
|
||||
TestBean testBean = (TestBean) context.getBean("testBean");
|
||||
MessageChannel channel = (MessageChannel) context.getBean("input");
|
||||
channel.send(new GenericMessage<>("test-1"));
|
||||
channel.send(new GenericMessage<>("test-2"));
|
||||
channel.send(new GenericMessage<>("test-3"));
|
||||
channel.send(new GenericMessage<>("test-4"));
|
||||
channel.send(new GenericMessage<>("test-5"));
|
||||
List<Integer> calls = testBean.calls;
|
||||
assertThat(calls.size()).isEqualTo(5);
|
||||
assertThat(calls.get(0).intValue()).isEqualTo(1);
|
||||
assertThat(calls.get(1).intValue()).isEqualTo(2);
|
||||
assertThat(calls.get(2).intValue()).isEqualTo(3);
|
||||
assertThat(calls.get(3).intValue()).isEqualTo(4);
|
||||
assertThat(calls.get(4).intValue()).isEqualTo(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,10 +32,10 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.IntegrationConverter;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.handler.LambdaMessageProcessor;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
@@ -77,7 +78,6 @@ import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.support.MutableMessageBuilder;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
import org.springframework.integration.transformer.PayloadSerializingTransformer;
|
||||
import org.springframework.integration.util.NoBeansOverrideAnnotationConfigContextLoader;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -602,7 +602,7 @@ public class IntegrationFlowTests {
|
||||
@Bean
|
||||
public IntegrationFlow supplierFlow2() {
|
||||
return IntegrationFlow.fromSupplier(() -> "foo",
|
||||
c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1)))
|
||||
c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1)))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel("suppliedChannel2")
|
||||
.get();
|
||||
@@ -948,7 +948,7 @@ public class IntegrationFlowTests {
|
||||
@Bean
|
||||
public IntegrationFlow globalErrorChannelResolutionFlow(@Qualifier("taskScheduler") TaskExecutor taskExecutor) {
|
||||
return IntegrationFlow.from(Consumer.class,
|
||||
(gateway) -> gateway.beanName("globalErrorChannelResolutionFunction"))
|
||||
(gateway) -> gateway.beanName("globalErrorChannelResolutionFunction"))
|
||||
.channel(c -> c.executor(taskExecutor))
|
||||
.handle((p, h) -> {
|
||||
throw new RuntimeException("intentional");
|
||||
@@ -1047,4 +1047,3 @@ public class IntegrationFlowTests {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2022 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,8 +28,8 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
@@ -79,6 +79,7 @@ public class MessagingMethodInvocableHelperTests {
|
||||
public String handle(Map<String, String> mapPayload, MessageHeaders messageHeaders) {
|
||||
return "Hello " + mapPayload.get("key");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class StringHandler implements GenericHandler<String> {
|
||||
@@ -87,6 +88,7 @@ public class MessagingMethodInvocableHelperTests {
|
||||
public String handle(String stringPayload, MessageHeaders messageHeaders) {
|
||||
return stringPayload + " World!";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -33,12 +32,12 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.GenericHandler;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.event.core.MessagingEvent;
|
||||
import org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer;
|
||||
import org.springframework.integration.event.outbound.ApplicationEventPublishingMessageHandler;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -47,22 +46,22 @@ import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class IntegrationFlowEventsTests {
|
||||
|
||||
private static MessageGroupStore messageGroupStore = new SimpleMessageStore();
|
||||
private static final MessageGroupStore messageGroupStore = new SimpleMessageStore();
|
||||
|
||||
private static String GROUP_ID = "testGroup";
|
||||
private static final String GROUP_ID = "testGroup";
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void setup() {
|
||||
messageGroupStore.addMessageToGroup(GROUP_ID, new GenericMessage<>("foo"));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ The following changes have been made in version 5.1:
|
||||
The `IntegrationFlowContext` is now an interface and `IntegrationFlowRegistration` is an inner interface of `IntegrationFlowContext`.
|
||||
|
||||
A new `logAndReply()` operator has been introduced for convenience when you wish to log at the end of a flow for request-reply configurations.
|
||||
This avoid confusion with `log()` which is treated as a one-way end flow component.
|
||||
This avoids confusion with `log()` which is treated as a one-way end flow component.
|
||||
|
||||
A generated bean name for any `NamedComponent` within an integration flow is now based on the component type for better readability from visual tools, logs analyzers and metrics collectors.
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public IntegrationFlow integerFlow() {
|
||||
====
|
||||
|
||||
The `transform` method accepts a lambda as an endpoint argument to operate on the message payload.
|
||||
The real argument of this method is `GenericTransformer<S, T>`.
|
||||
The real argument of this method is a `GenericTransformer<S, T>` instance.
|
||||
Consequently, any of the provided transformers (`ObjectToJsonTransformer`, `FileToStringTransformer`, and other) can be used here.
|
||||
|
||||
Under the covers, `IntegrationFlowBuilder` recognizes the `MessageHandler` and the endpoint for it, with `MessageTransformingHandler` and `ConsumerEndpointFactoryBean`, respectively.
|
||||
@@ -1300,7 +1300,7 @@ With Java 8, you can even create an integration gateway with the `java.util.func
|
||||
@Bean
|
||||
public IntegrationFlow errorRecovererFlow() {
|
||||
return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
|
||||
.handle((GenericHandler<?>) (p, h) -> {
|
||||
.<Object>handle((p, h) -> {
|
||||
throw new RuntimeException("intentional");
|
||||
}, e -> e.advice(retryAdvice()))
|
||||
.get();
|
||||
@@ -1432,4 +1432,4 @@ IntegrationFlow otherFlow() {
|
||||
|
||||
The composition in the middle of the flow is simply achievable with an existing `gateway(IntegrationFlow)` EIP-method.
|
||||
This way we can build flows with any complexity by composing them from simpler, reusable logical blocks.
|
||||
For example, you may add a library of `IntegrationFlow` beans as a dependency and it is just enough to have their configuration classes imported to the final project and autowired for your `IntegrationFlow` definitions.
|
||||
For example, you may add a library of `IntegrationFlow` beans as a dependency and it is just enough to have their configuration classes imported to the final project and autowired for your `IntegrationFlow` definitions.
|
||||
|
||||
@@ -433,7 +433,7 @@ public class EerhaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow advised() {
|
||||
return f -> f.handle((GenericHandler<String>) (payload, headers) -> {
|
||||
return f -> f.<String>handle((payload, headers) -> {
|
||||
if (payload.equals("good")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user