GH-3623: Deprecarte an IntegrationFlows
Fixes https://github.com/spring-projects/spring-integration/issues/3623 * `IntegrationFlow` refactoring * Apply several code style improvements and good practices * Code style: no empty lines for methods javadocs * make deprecated implementation reuse actual one instead of the copy-paste approach * add whats-new comments * Fix whats-new page according to standards
This commit is contained in:
committed by
GitHub
parent
63759d76b9
commit
53dd050c5b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2020 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.
|
||||
@@ -59,7 +59,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowBuilder;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
@@ -161,7 +160,7 @@ public class AmqpTests {
|
||||
|
||||
@Test
|
||||
public void testTemplateChannelTransacted() {
|
||||
IntegrationFlowBuilder flow = IntegrationFlows.from(Amqp.channel("testTemplateChannelTransacted",
|
||||
IntegrationFlowBuilder flow = IntegrationFlow.from(Amqp.channel("testTemplateChannelTransacted",
|
||||
this.rabbitConnectionFactory)
|
||||
.autoStartup(false)
|
||||
.templateChannelTransacted(true));
|
||||
@@ -235,7 +234,7 @@ public class AmqpTests {
|
||||
@Test
|
||||
void testContentTypeOverrideWithReplyHeadersMappedLast() {
|
||||
IntegrationFlow testFlow =
|
||||
IntegrationFlows
|
||||
IntegrationFlow
|
||||
.from(Amqp.inboundGateway(this.rabbitConnectionFactory, this.amqpQueue2)
|
||||
.replyHeadersMappedLast(true))
|
||||
.transform(Transformers.fromJson())
|
||||
@@ -300,7 +299,7 @@ public class AmqpTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow amqpFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Amqp.inboundGateway(rabbitConnectionFactory, amqpTemplate, queue())
|
||||
.id("amqpInboundGateway")
|
||||
.configureContainer(c -> c
|
||||
@@ -315,7 +314,7 @@ public class AmqpTests {
|
||||
|
||||
// syntax only
|
||||
public IntegrationFlow amqpDMLCFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Amqp.inboundGateway(new DirectMessageListenerContainer())
|
||||
.id("amqpInboundGateway")
|
||||
.configureContainer(c -> c
|
||||
@@ -329,7 +328,7 @@ public class AmqpTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow amqpOutboundFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) {
|
||||
return IntegrationFlows.from(Amqp.channel("amqpOutboundInput", rabbitConnectionFactory))
|
||||
return IntegrationFlow.from(Amqp.channel("amqpOutboundInput", rabbitConnectionFactory))
|
||||
.handle(Amqp.outboundAdapter(amqpTemplate).routingKeyExpression("headers.routingKey"))
|
||||
.get();
|
||||
}
|
||||
@@ -346,7 +345,7 @@ public class AmqpTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow amqpInboundFlow(ConnectionFactory rabbitConnectionFactory) {
|
||||
return IntegrationFlows.from(Amqp.inboundAdapter(rabbitConnectionFactory, fooQueue())
|
||||
return IntegrationFlow.from(Amqp.inboundAdapter(rabbitConnectionFactory, fooQueue())
|
||||
.configureContainer(container -> container.consumerBatchEnabled(true)
|
||||
.batchSize(2))
|
||||
.batchMode(BatchMode.EXTRACT_PAYLOADS)
|
||||
@@ -384,7 +383,7 @@ public class AmqpTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow inboundWithExceptionFlow(ConnectionFactory cf) {
|
||||
return IntegrationFlows.from(Amqp.inboundAdapter(cf, exQueue())
|
||||
return IntegrationFlow.from(Amqp.inboundAdapter(cf, exQueue())
|
||||
.configureContainer(c -> c.defaultRequeueRejected(false))
|
||||
.errorChannel("errors.input"))
|
||||
.handle(m -> {
|
||||
@@ -421,7 +420,7 @@ public class AmqpTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow inboundWithConvExceptionFlow(ConnectionFactory cf) {
|
||||
return IntegrationFlows.from(Amqp.inboundAdapter(cf, exConvQueue())
|
||||
return IntegrationFlow.from(Amqp.inboundAdapter(cf, exConvQueue())
|
||||
.configureContainer(c -> c.defaultRequeueRejected(false))
|
||||
.messageConverter(new SimpleMessageConverter() {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -54,7 +54,6 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
@@ -198,7 +197,7 @@ public class AmqpMessageSourceIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE),
|
||||
return IntegrationFlow.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE),
|
||||
e -> e.poller(Pollers.fixedDelay(100)).autoStartup(false))
|
||||
.handle(p -> {
|
||||
this.fromDsl = p.getPayload();
|
||||
@@ -209,7 +208,7 @@ public class AmqpMessageSourceIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow messageSourceChannelFlow() {
|
||||
return IntegrationFlows.from(interceptedSource(),
|
||||
return IntegrationFlow.from(interceptedSource(),
|
||||
e -> e.poller(Pollers.fixedDelay(100)).autoStartup(false))
|
||||
.handle(p -> {
|
||||
this.fromInterceptedSource = p.getPayload();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -41,7 +41,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.amqp.dsl.Amqp;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
@@ -108,7 +107,7 @@ public class BoundRabbitChannelAdviceIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow(RabbitTemplate template, BoundRabbitChannelAdvice advice) {
|
||||
return IntegrationFlows.from(Gate.class)
|
||||
return IntegrationFlow.from(Gate.class)
|
||||
.split(s -> s.delimiters(",")
|
||||
.advice(advice))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
@@ -118,7 +117,7 @@ public class BoundRabbitChannelAdviceIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow listener(CachingConnectionFactory ccf) {
|
||||
return IntegrationFlows.from(Amqp.inboundAdapter(ccf, QUEUE))
|
||||
return IntegrationFlow.from(Amqp.inboundAdapter(ccf, QUEUE))
|
||||
.handle(m -> {
|
||||
received.add((String) m.getPayload());
|
||||
this.latch.countDown();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-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,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.amqp.dsl.Amqp;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
@@ -121,7 +120,7 @@ public class BoundRabbitChannelAdviceTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow(RabbitTemplate template) {
|
||||
return IntegrationFlows.from(Gate.class)
|
||||
return IntegrationFlow.from(Gate.class)
|
||||
.split(s -> s.delimiters(",")
|
||||
.advice(new BoundRabbitChannelAdvice(template, Duration.ofSeconds(10))))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
|
||||
@@ -426,7 +426,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
MessageChannel messageChannel = flow.getInputChannel();
|
||||
if (messageChannel == null) {
|
||||
messageChannel = new DirectChannel();
|
||||
IntegrationFlowDefinition<?> flowBuilder = IntegrationFlows.from(messageChannel);
|
||||
IntegrationFlowDefinition<?> flowBuilder = IntegrationFlow.from(messageChannel);
|
||||
flow.configure(flowBuilder);
|
||||
addComponent(flowBuilder.get());
|
||||
}
|
||||
@@ -457,7 +457,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
*/
|
||||
public B wireTap(String wireTapChannel, Consumer<WireTapSpec> wireTapConfigurer) {
|
||||
DirectChannel internalWireTapChannel = new DirectChannel();
|
||||
addComponent(IntegrationFlows.from(internalWireTapChannel).channel(wireTapChannel).get());
|
||||
addComponent(IntegrationFlow.from(internalWireTapChannel).channel(wireTapChannel).get());
|
||||
return wireTap(internalWireTapChannel, wireTapConfigurer);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -58,7 +58,7 @@ public class BroadcastPublishSubscribeSpec
|
||||
Assert.notNull(subFlow, "'subFlow' must not be null");
|
||||
|
||||
IntegrationFlowBuilder flowBuilder =
|
||||
IntegrationFlows.from(this.target)
|
||||
IntegrationFlow.from(this.target)
|
||||
.bridge(consumer -> consumer.order(this.order++));
|
||||
|
||||
MessageChannel subFlowInput = subFlow.getInputChannel();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -163,7 +163,7 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
|
||||
MessageChannel messageChannel = subFlow.getInputChannel();
|
||||
if (messageChannel == null) {
|
||||
messageChannel = new DirectChannel();
|
||||
IntegrationFlowDefinition<?> flowBuilder = IntegrationFlows.from(messageChannel);
|
||||
IntegrationFlowDefinition<?> flowBuilder = IntegrationFlow.from(messageChannel);
|
||||
subFlow.configure(flowBuilder);
|
||||
this.componentsToRegister.put(evaluateInternalBuilder ? flowBuilder.get() : flowBuilder, null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -17,8 +17,29 @@
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.handler.AbstractMessageProducingHandler;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The main Integration DSL abstraction.
|
||||
@@ -29,7 +50,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
* <pre class="code">
|
||||
* @Bean
|
||||
* public IntegrationFlow fileReadingFlow() {
|
||||
* return IntegrationFlows
|
||||
* return IntegrationFlow
|
||||
* .from(Files.inboundAdapter(tmpDir.getRoot()), e -> e.poller(Pollers.fixedDelay(100)))
|
||||
* .transform(Files.fileToString())
|
||||
* .channel(MessageChannels.queue("fileReadingResultChannel"))
|
||||
@@ -67,6 +88,9 @@ import org.springframework.messaging.MessageChannel;
|
||||
* </pre>
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Vozhdayenko
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
@@ -103,4 +127,386 @@ public interface IntegrationFlow {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageChannel} name to the new {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code inputChannel}.
|
||||
* @param messageChannelName the name of existing {@link MessageChannel} bean.
|
||||
* The new {@link DirectChannel} bean will be created on context startup
|
||||
* if there is no bean with this name.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(String messageChannelName) {
|
||||
return from(new MessageChannelReference(messageChannelName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageChannel} object to the
|
||||
* {@link IntegrationFlowBuilder} chain using the fluent API from {@link MessageChannelSpec}.
|
||||
* The {@link IntegrationFlow} {@code inputChannel}.
|
||||
* @param messageChannelSpec the MessageChannelSpec to populate {@link MessageChannel} instance.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageChannels
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageChannelSpec<?, ?> messageChannelSpec) {
|
||||
Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null");
|
||||
return from(messageChannelSpec.get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageChannel} name to the new {@link IntegrationFlowBuilder} chain.
|
||||
* Typically for the {@link org.springframework.integration.channel.FixedSubscriberChannel} together
|
||||
* with {@code fixedSubscriber = true}.
|
||||
* The {@link IntegrationFlow} {@code inputChannel}.
|
||||
* @param messageChannelName the name for {@link DirectChannel} or
|
||||
* {@link org.springframework.integration.channel.FixedSubscriberChannel}
|
||||
* to be created on context startup, not reference.
|
||||
* The {@link MessageChannel} depends on the {@code fixedSubscriber} boolean argument.
|
||||
* @param fixedSubscriber the boolean flag to determine if result {@link MessageChannel} should
|
||||
* be {@link DirectChannel}, if {@code false} or
|
||||
* {@link org.springframework.integration.channel.FixedSubscriberChannel}, if {@code true}.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see DirectChannel
|
||||
* @see org.springframework.integration.channel.FixedSubscriberChannel
|
||||
*/
|
||||
static IntegrationFlowBuilder from(String messageChannelName, boolean fixedSubscriber) {
|
||||
return fixedSubscriber
|
||||
? from(new FixedSubscriberChannelPrototype(messageChannelName))
|
||||
: from(messageChannelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the provided {@link MessageChannel} object to the {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code inputChannel}.
|
||||
* @param messageChannel the {@link MessageChannel} to populate.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageChannel messageChannel) {
|
||||
return new IntegrationFlowBuilder().channel(messageChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain
|
||||
* using the fluent API from the provided {@link MessageSourceSpec}.
|
||||
* The {@link IntegrationFlow} {@code startMessageSource}.
|
||||
* @param messageSourceSpec the {@link MessageSourceSpec} to use.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageSourceSpec and its implementations.
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec) {
|
||||
return from(messageSourceSpec, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain
|
||||
* using the fluent API from the provided {@link MessageSourceSpec}.
|
||||
* The {@link IntegrationFlow} {@code startMessageSource}.
|
||||
* @param messageSourceSpec the {@link MessageSourceSpec} to use.
|
||||
* @param endpointConfigurer the {@link Consumer} to provide more options for the
|
||||
* {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageSourceSpec
|
||||
* @see SourcePollingChannelAdapterSpec
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
Assert.notNull(messageSourceSpec, "'messageSourceSpec' must not be null");
|
||||
return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides {@link Supplier} as source of messages to the integration flow which will
|
||||
* be triggered by the application context's default poller (which must be declared).
|
||||
* @param messageSource the {@link Supplier} to populate.
|
||||
* @param <T> the supplier type.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see Supplier
|
||||
*/
|
||||
static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource) {
|
||||
return fromSupplier(messageSource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides {@link Supplier} as source of messages to the integration flow.
|
||||
* which will be triggered by a <b>provided</b>
|
||||
* {@link org.springframework.integration.endpoint.SourcePollingChannelAdapter}.
|
||||
* @param messageSource the {@link Supplier} to populate.
|
||||
* @param endpointConfigurer the {@link Consumer} to provide more options for the
|
||||
* {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}.
|
||||
* @param <T> the supplier type.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see Supplier
|
||||
*/
|
||||
static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(messageSource, "'messageSource' must not be null");
|
||||
return from(new AbstractMessageSource<Object>() {
|
||||
|
||||
@Override
|
||||
protected Object doReceive() {
|
||||
return messageSource.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "inbound-channel-adapter";
|
||||
}
|
||||
|
||||
}, endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the provided {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code startMessageSource}.
|
||||
* @param messageSource the {@link MessageSource} to populate.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageSource
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageSource<?> messageSource) {
|
||||
return from(messageSource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the provided {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code startMessageSource}.
|
||||
* In addition use {@link SourcePollingChannelAdapterSpec} to provide options for the underlying
|
||||
* {@link org.springframework.integration.endpoint.SourcePollingChannelAdapter} endpoint.
|
||||
* @param messageSource the {@link MessageSource} to populate.
|
||||
* @param endpointConfigurer the {@link Consumer} to provide more options for the
|
||||
* {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageSource
|
||||
* @see SourcePollingChannelAdapterSpec
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
@Nullable Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
return from(messageSource, endpointConfigurer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
@Nullable Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
SourcePollingChannelAdapterSpec spec = new SourcePollingChannelAdapterSpec(messageSource);
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(spec);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = new IntegrationFlowBuilder();
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(spec)
|
||||
.currentComponent(spec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageProducerSupport} object to the {@link IntegrationFlowBuilder} chain
|
||||
* using the fluent API from the {@link MessageProducerSpec}.
|
||||
* The {@link IntegrationFlow} {@code startMessageProducer}.
|
||||
* @param messageProducerSpec the {@link MessageProducerSpec} to use.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
* @see MessageProducerSpec
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageProducerSpec<?, ?> messageProducerSpec) {
|
||||
return from(messageProducerSpec.get(), registerComponents(messageProducerSpec));
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the provided {@link MessageProducerSupport} object to the {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code startMessageProducer}.
|
||||
* @param messageProducer the {@link MessageProducerSupport} to populate.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessageProducerSupport messageProducer) {
|
||||
return from(messageProducer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
MessageChannel outputChannel = messageProducer.getOutputChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
messageProducer.setOutputChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(messageProducer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessagingGatewaySupport} object to the {@link IntegrationFlowBuilder} chain
|
||||
* using the fluent API from the {@link MessagingGatewaySpec}.
|
||||
* The {@link IntegrationFlow} {@code startMessagingGateway}.
|
||||
* @param inboundGatewaySpec the {@link MessagingGatewaySpec} to use.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessagingGatewaySpec<?, ?> inboundGatewaySpec) {
|
||||
return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec));
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the provided {@link MessagingGatewaySupport} object to the {@link IntegrationFlowBuilder} chain.
|
||||
* The {@link IntegrationFlow} {@code startMessageProducer}.
|
||||
* @param inboundGateway the {@link MessagingGatewaySupport} to populate.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway) {
|
||||
return from(inboundGateway, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageChannel} to the new {@link IntegrationFlowBuilder}
|
||||
* chain, which becomes as a {@code requestChannel} for the Messaging Gateway(s) built
|
||||
* on the provided service interface.
|
||||
* <p>A gateway proxy bean for provided service interface is registered under a name
|
||||
* from the
|
||||
* {@link org.springframework.integration.annotation.MessagingGateway#name()} if present
|
||||
* or from the {@link IntegrationFlow} bean name plus {@code .gateway} suffix.
|
||||
* @param serviceInterface the service interface class with an optional
|
||||
* {@link org.springframework.integration.annotation.MessagingGateway} annotation.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(Class<?> serviceInterface) {
|
||||
return from(serviceInterface, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the {@link MessageChannel} to the new {@link IntegrationFlowBuilder}
|
||||
* chain, which becomes as a {@code requestChannel} for the Messaging Gateway(s) built
|
||||
* on the provided service interface.
|
||||
* <p>A gateway proxy bean for provided service interface is based on the options
|
||||
* configured via provided {@link Consumer}.
|
||||
* @param serviceInterface the service interface class with an optional
|
||||
* {@link org.springframework.integration.annotation.MessagingGateway} annotation.
|
||||
* @param endpointConfigurer the {@link Consumer} to configure proxy bean for gateway.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
static IntegrationFlowBuilder from(Class<?> serviceInterface,
|
||||
@Nullable Consumer<GatewayProxySpec> endpointConfigurer) {
|
||||
|
||||
GatewayProxySpec gatewayProxySpec = new GatewayProxySpec(serviceInterface);
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(gatewayProxySpec);
|
||||
}
|
||||
|
||||
return from(gatewayProxySpec.getGatewayRequestChannel())
|
||||
.addComponent(gatewayProxySpec.getGatewayProxyFactoryBean());
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate a {@link FluxMessageChannel} to the {@link IntegrationFlowBuilder} chain
|
||||
* and subscribe it to the provided {@link Publisher}.
|
||||
* @param publisher the {@link Publisher} to subscribe to.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
@SuppressWarnings("overloads")
|
||||
static IntegrationFlowBuilder from(Publisher<? extends Message<?>> publisher) {
|
||||
FluxMessageChannel reactiveChannel = new FluxMessageChannel();
|
||||
reactiveChannel.subscribeTo(publisher);
|
||||
return from((MessageChannel) reactiveChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the flow with a composition from the {@link IntegrationFlow}.
|
||||
* @param other the {@link IntegrationFlow} from which to compose.
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
* @since 6.0
|
||||
*/
|
||||
@SuppressWarnings("overloads")
|
||||
static IntegrationFlowBuilder from(IntegrationFlow other) {
|
||||
Map<Object, String> integrationComponents = other.getIntegrationComponents();
|
||||
Assert.notNull(integrationComponents, () ->
|
||||
"The provided integration flow to compose from '" + other +
|
||||
"' must be declared as a bean in the application context");
|
||||
Object lastIntegrationComponentFromOther =
|
||||
integrationComponents.keySet().stream().reduce((prev, next) -> next).orElse(null);
|
||||
if (lastIntegrationComponentFromOther instanceof MessageChannel) {
|
||||
return from((MessageChannel) lastIntegrationComponentFromOther);
|
||||
}
|
||||
else if (lastIntegrationComponentFromOther instanceof ConsumerEndpointFactoryBean) {
|
||||
MessageHandler handler = ((ConsumerEndpointFactoryBean) lastIntegrationComponentFromOther).getHandler();
|
||||
handler = extractProxyTarget(handler);
|
||||
if (handler instanceof AbstractMessageProducingHandler) {
|
||||
return buildFlowFromOutputChannel((AbstractMessageProducingHandler) handler);
|
||||
}
|
||||
lastIntegrationComponentFromOther = handler; // for the exception message below
|
||||
}
|
||||
throw new BeanCreationException("The 'IntegrationFlow' to start from must end with " +
|
||||
"a 'MessageChannel' or reply-producing endpoint to let the result from that flow to be " +
|
||||
"processed in this instance. The provided flow ends with: " + lastIntegrationComponentFromOther);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder buildFlowFromOutputChannel(AbstractMessageProducingHandler handler) {
|
||||
MessageChannel outputChannel = handler.getOutputChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new PublishSubscribeChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
}
|
||||
return from(outputChannel);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
MessageChannel outputChannel = inboundGateway.getRequestChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
inboundGateway.setRequestChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(inboundGateway);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder registerComponents(Object spec) {
|
||||
if (spec instanceof ComponentsRegistration) {
|
||||
return new IntegrationFlowBuilder()
|
||||
.addComponents(((ComponentsRegistration) spec).getComponentsToRegister());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T extractProxyTarget(T target) {
|
||||
if (!(target instanceof Advised)) {
|
||||
return target;
|
||||
}
|
||||
Advised advised = (Advised) target;
|
||||
try {
|
||||
return (T) extractProxyTarget(advised.getTargetSource().getTarget());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Could not extract target", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -133,69 +133,69 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, Managea
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(String messageChannelName) {
|
||||
return IntegrationFlows.from(messageChannelName);
|
||||
return IntegrationFlow.from(messageChannelName);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageChannel messageChannel) {
|
||||
return IntegrationFlows.from(messageChannel);
|
||||
return IntegrationFlow.from(messageChannel);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(String messageChannelName, boolean fixedSubscriber) {
|
||||
return IntegrationFlows.from(messageChannelName, fixedSubscriber);
|
||||
return IntegrationFlow.from(messageChannelName, fixedSubscriber);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
return IntegrationFlows.from(messageSourceSpec, endpointConfigurer);
|
||||
return IntegrationFlow.from(messageSourceSpec, endpointConfigurer);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageSource<?> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
return IntegrationFlows.from(messageSource, endpointConfigurer);
|
||||
return IntegrationFlow.from(messageSource, endpointConfigurer);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageProducerSupport messageProducer) {
|
||||
return IntegrationFlows.from(messageProducer);
|
||||
return IntegrationFlow.from(messageProducer);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageSource<?> messageSource) {
|
||||
return IntegrationFlows.from(messageSource);
|
||||
return IntegrationFlow.from(messageSource);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessagingGatewaySupport inboundGateway) {
|
||||
return IntegrationFlows.from(inboundGateway);
|
||||
return IntegrationFlow.from(inboundGateway);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageChannelSpec<?, ?> messageChannelSpec) {
|
||||
return IntegrationFlows.from(messageChannelSpec);
|
||||
return IntegrationFlow.from(messageChannelSpec);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageProducerSpec<?, ?> messageProducerSpec) {
|
||||
return IntegrationFlows.from(messageProducerSpec);
|
||||
return IntegrationFlow.from(messageProducerSpec);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec) {
|
||||
return IntegrationFlows.from(messageSourceSpec);
|
||||
return IntegrationFlow.from(messageSourceSpec);
|
||||
}
|
||||
|
||||
protected IntegrationFlowDefinition<?> from(MessagingGatewaySpec<?, ?> inboundGatewaySpec) {
|
||||
return IntegrationFlows.from(inboundGatewaySpec);
|
||||
return IntegrationFlow.from(inboundGatewaySpec);
|
||||
}
|
||||
|
||||
protected <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource) {
|
||||
return IntegrationFlows.fromSupplier(messageSource);
|
||||
return IntegrationFlow.fromSupplier(messageSource);
|
||||
}
|
||||
|
||||
protected <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
return IntegrationFlows.fromSupplier(messageSource, endpointConfigurer);
|
||||
return IntegrationFlow.fromSupplier(messageSource, endpointConfigurer);
|
||||
}
|
||||
|
||||
protected IntegrationFlowBuilder from(Class<?> serviceInterface) {
|
||||
return IntegrationFlows.from(serviceInterface);
|
||||
return IntegrationFlow.from(serviceInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,11 +208,11 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, Managea
|
||||
protected IntegrationFlowBuilder from(Class<?> serviceInterface,
|
||||
@Nullable Consumer<GatewayProxySpec> endpointConfigurer) {
|
||||
|
||||
return IntegrationFlows.from(serviceInterface, endpointConfigurer);
|
||||
return IntegrationFlow.from(serviceInterface, endpointConfigurer);
|
||||
}
|
||||
|
||||
protected IntegrationFlowBuilder from(Publisher<? extends Message<?>> publisher) {
|
||||
return IntegrationFlows.from(publisher);
|
||||
return IntegrationFlow.from(publisher);
|
||||
}
|
||||
|
||||
protected abstract IntegrationFlowDefinition<?> buildFlow();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -16,30 +16,19 @@
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.handler.AbstractMessageProducingHandler;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* The central factory for fluent {@link IntegrationFlowBuilder} API.
|
||||
@@ -51,7 +40,10 @@ import org.springframework.util.Assert;
|
||||
* @since 5.0
|
||||
*
|
||||
* @see org.springframework.integration.dsl.context.IntegrationFlowBeanPostProcessor
|
||||
*
|
||||
* @deprecated Since version 6.0, this factory is not recommended to use as it shall be removed in the following versions. Use fluent API methods straight from {@link IntegrationFlow} interface.
|
||||
*/
|
||||
@Deprecated(since = "6.0", forRemoval = true)
|
||||
public final class IntegrationFlows {
|
||||
|
||||
/**
|
||||
@@ -63,7 +55,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(String messageChannelName) {
|
||||
return from(new MessageChannelReference(messageChannelName));
|
||||
return IntegrationFlow.from(messageChannelName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,9 +75,7 @@ public final class IntegrationFlows {
|
||||
* @see org.springframework.integration.channel.FixedSubscriberChannel
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(String messageChannelName, boolean fixedSubscriber) {
|
||||
return fixedSubscriber
|
||||
? from(new FixedSubscriberChannelPrototype(messageChannelName))
|
||||
: from(messageChannelName);
|
||||
return IntegrationFlow.from(messageChannelName, fixedSubscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +87,7 @@ public final class IntegrationFlows {
|
||||
* @see org.springframework.integration.dsl.MessageChannels
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageChannelSpec<?, ?> messageChannelSpec) {
|
||||
Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null");
|
||||
return from(messageChannelSpec.get());
|
||||
return IntegrationFlow.from(messageChannelSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +97,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageChannel messageChannel) {
|
||||
return new IntegrationFlowBuilder().channel(messageChannel);
|
||||
return IntegrationFlow.from(messageChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +109,7 @@ public final class IntegrationFlows {
|
||||
* @see MessageSourceSpec and its implementations.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec) {
|
||||
return from(messageSourceSpec, null);
|
||||
return IntegrationFlow.from(messageSourceSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,8 +125,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageSourceSpec<?, ? extends MessageSource<?>> messageSourceSpec,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
Assert.notNull(messageSourceSpec, "'messageSourceSpec' must not be null");
|
||||
return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec));
|
||||
return IntegrationFlow.from(messageSourceSpec, endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +137,7 @@ public final class IntegrationFlows {
|
||||
* @see Supplier
|
||||
*/
|
||||
public static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource) {
|
||||
return fromSupplier(messageSource, null);
|
||||
return IntegrationFlow.fromSupplier(messageSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,21 +153,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
public static <T> IntegrationFlowBuilder fromSupplier(Supplier<T> messageSource,
|
||||
Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(messageSource, "'messageSource' must not be null");
|
||||
return from(new AbstractMessageSource<Object>() {
|
||||
|
||||
@Override
|
||||
protected Object doReceive() {
|
||||
return messageSource.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "inbound-channel-adapter";
|
||||
}
|
||||
|
||||
}, endpointConfigurer);
|
||||
return IntegrationFlow.fromSupplier(messageSource, endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +164,7 @@ public final class IntegrationFlows {
|
||||
* @see MessageSource
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageSource<?> messageSource) {
|
||||
return from(messageSource, null);
|
||||
return IntegrationFlow.from(messageSource);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,24 +181,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
@Nullable Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer) {
|
||||
|
||||
return from(messageSource, endpointConfigurer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageSource<?> messageSource,
|
||||
@Nullable Consumer<SourcePollingChannelAdapterSpec> endpointConfigurer,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
SourcePollingChannelAdapterSpec spec = new SourcePollingChannelAdapterSpec(messageSource);
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(spec);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = new IntegrationFlowBuilder();
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(spec)
|
||||
.currentComponent(spec);
|
||||
return IntegrationFlow.from(messageSource, endpointConfigurer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +193,7 @@ public final class IntegrationFlows {
|
||||
* @see MessageProducerSpec
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageProducerSpec<?, ?> messageProducerSpec) {
|
||||
return from(messageProducerSpec.get(), registerComponents(messageProducerSpec));
|
||||
return IntegrationFlow.from(messageProducerSpec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,25 +203,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessageProducerSupport messageProducer) {
|
||||
return from(messageProducer, null);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
MessageChannel outputChannel = messageProducer.getOutputChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
messageProducer.setOutputChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(messageProducer);
|
||||
return IntegrationFlow.from(messageProducer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +214,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessagingGatewaySpec<?, ?> inboundGatewaySpec) {
|
||||
return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec));
|
||||
return IntegrationFlow.from(inboundGatewaySpec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,7 +224,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway) {
|
||||
return from(inboundGateway, null);
|
||||
return IntegrationFlow.from(inboundGateway);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +240,7 @@ public final class IntegrationFlows {
|
||||
* @return new {@link IntegrationFlowBuilder}.
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(Class<?> serviceInterface) {
|
||||
return from(serviceInterface, null);
|
||||
return IntegrationFlow.from(serviceInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,14 +257,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
public static IntegrationFlowBuilder from(Class<?> serviceInterface,
|
||||
@Nullable Consumer<GatewayProxySpec> endpointConfigurer) {
|
||||
|
||||
GatewayProxySpec gatewayProxySpec = new GatewayProxySpec(serviceInterface);
|
||||
if (endpointConfigurer != null) {
|
||||
endpointConfigurer.accept(gatewayProxySpec);
|
||||
}
|
||||
|
||||
return from(gatewayProxySpec.getGatewayRequestChannel())
|
||||
.addComponent(gatewayProxySpec.getGatewayProxyFactoryBean());
|
||||
return IntegrationFlow.from(serviceInterface, endpointConfigurer);
|
||||
}
|
||||
|
||||
|
||||
@@ -337,9 +269,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
@SuppressWarnings("overloads")
|
||||
public static IntegrationFlowBuilder from(Publisher<? extends Message<?>> publisher) {
|
||||
FluxMessageChannel reactiveChannel = new FluxMessageChannel();
|
||||
reactiveChannel.subscribeTo(publisher);
|
||||
return from((MessageChannel) reactiveChannel);
|
||||
return IntegrationFlow.from(publisher);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -350,75 +280,7 @@ public final class IntegrationFlows {
|
||||
*/
|
||||
@SuppressWarnings("overloads")
|
||||
public static IntegrationFlowBuilder from(IntegrationFlow other) {
|
||||
Map<Object, String> integrationComponents = other.getIntegrationComponents();
|
||||
Assert.notNull(integrationComponents, () ->
|
||||
"The provided integration flow to compose from '" + other +
|
||||
"' must be declared as a bean in the application context");
|
||||
Object lastIntegrationComponentFromOther =
|
||||
integrationComponents.keySet().stream().reduce((prev, next) -> next).orElse(null);
|
||||
if (lastIntegrationComponentFromOther instanceof MessageChannel) {
|
||||
return from((MessageChannel) lastIntegrationComponentFromOther);
|
||||
}
|
||||
else if (lastIntegrationComponentFromOther instanceof ConsumerEndpointFactoryBean) {
|
||||
MessageHandler handler = ((ConsumerEndpointFactoryBean) lastIntegrationComponentFromOther).getHandler();
|
||||
handler = extractProxyTarget(handler);
|
||||
if (handler instanceof AbstractMessageProducingHandler) {
|
||||
return buildFlowFromOutputChannel((AbstractMessageProducingHandler) handler);
|
||||
}
|
||||
lastIntegrationComponentFromOther = handler; // for the exception message below
|
||||
}
|
||||
throw new BeanCreationException("The 'IntegrationFlow' to start from must end with " +
|
||||
"a 'MessageChannel' or reply-producing endpoint to let the result from that flow to be " +
|
||||
"processed in this instance. The provided flow ends with: " + lastIntegrationComponentFromOther);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder buildFlowFromOutputChannel(AbstractMessageProducingHandler handler) {
|
||||
MessageChannel outputChannel = handler.getOutputChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new PublishSubscribeChannel();
|
||||
handler.setOutputChannel(outputChannel);
|
||||
}
|
||||
return from(outputChannel);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway,
|
||||
@Nullable IntegrationFlowBuilder integrationFlowBuilderArg) {
|
||||
|
||||
IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg;
|
||||
MessageChannel outputChannel = inboundGateway.getRequestChannel();
|
||||
if (outputChannel == null) {
|
||||
outputChannel = new DirectChannel();
|
||||
inboundGateway.setRequestChannel(outputChannel);
|
||||
}
|
||||
if (integrationFlowBuilder == null) {
|
||||
integrationFlowBuilder = from(outputChannel);
|
||||
}
|
||||
else {
|
||||
integrationFlowBuilder.channel(outputChannel);
|
||||
}
|
||||
return integrationFlowBuilder.addComponent(inboundGateway);
|
||||
}
|
||||
|
||||
private static IntegrationFlowBuilder registerComponents(Object spec) {
|
||||
if (spec instanceof ComponentsRegistration) {
|
||||
return new IntegrationFlowBuilder()
|
||||
.addComponents(((ComponentsRegistration) spec).getComponentsToRegister());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T extractProxyTarget(T target) {
|
||||
if (!(target instanceof Advised)) {
|
||||
return target;
|
||||
}
|
||||
Advised advised = (Advised) target;
|
||||
try {
|
||||
return (T) extractProxyTarget(advised.getTargetSource().getTarget());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanCreationException("Could not extract target", e);
|
||||
}
|
||||
return IntegrationFlow.from(other);
|
||||
}
|
||||
|
||||
private IntegrationFlows() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -62,7 +62,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
* @see IntegrationFlows
|
||||
* @see IntegrationFlow
|
||||
* @see org.springframework.integration.dsl.context.IntegrationFlowBeanPostProcessor
|
||||
* @see org.springframework.integration.dsl.context.IntegrationFlowContext
|
||||
* @see SmartLifecycle
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -65,7 +65,6 @@ import org.springframework.integration.dsl.IntegrationComponentSpec;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowAdapter;
|
||||
import org.springframework.integration.dsl.IntegrationFlowBuilder;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
import org.springframework.integration.dsl.support.MessageChannelReference;
|
||||
@@ -309,7 +308,7 @@ public class IntegrationFlowBeanPostProcessor
|
||||
* see its javadocs for more information.
|
||||
*/
|
||||
private Object processIntegrationFlowImpl(IntegrationFlow flow, String beanName) {
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(beanName + ".input");
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlow.from(beanName + ".input");
|
||||
|
||||
flow.configure(flowBuilder);
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ fun integrationFlow(flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(Class<?>, Consumer<GatewayProxySpec>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(Class<?>, Consumer<GatewayProxySpec>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@@ -47,121 +47,121 @@ inline fun <reified T> integrationFlow(
|
||||
crossinline gateway: GatewayProxySpec.() -> Unit = {},
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit): IntegrationFlow {
|
||||
|
||||
val flowBuilder = IntegrationFlows.from(T::class.java) { gateway(it) }
|
||||
val flowBuilder = IntegrationFlow.from(T::class.java) { gateway(it) }
|
||||
KotlinIntegrationFlowDefinition(flowBuilder).flow()
|
||||
return flowBuilder.get()
|
||||
}
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(String, Boolean)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(String, Boolean)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(channelName: String, fixedSubscriber: Boolean = false,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(channelName, fixedSubscriber), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(channelName, fixedSubscriber), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessageChannel)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessageChannel)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(channel: MessageChannel, flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(channel), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(channel), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessageSource<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessageSource<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(messageSource: MessageSource<*>,
|
||||
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(messageSource) { options(it) }, flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(messageSource) { options(it) }, flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessageSourceSpec<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessageSourceSpec<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(messageSource: MessageSourceSpec<*, out MessageSource<*>>,
|
||||
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(messageSource, options), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(messageSource, options), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(Supplier<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(Supplier<*>, Consumer<SourcePollingChannelAdapterSpec>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(source: () -> Any,
|
||||
options: SourcePollingChannelAdapterSpec.() -> Unit = {},
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.fromSupplier(source, options), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.fromSupplier(source, options), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(Publisher<out Message<*>>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(Publisher<out Message<*>>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(publisher: Publisher<out Message<*>>,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(publisher), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(publisher), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessagingGatewaySupport)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessagingGatewaySupport)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(gateway: MessagingGatewaySupport,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(gateway), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(gateway), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessagingGatewaySpec<*, *>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessagingGatewaySpec<*, *>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(gatewaySpec: MessagingGatewaySpec<*, *>,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(gatewaySpec), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(gatewaySpec), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessageProducerSupport)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessageProducerSupport)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(producer: MessageProducerSupport,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(producer), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(producer), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(MessageProducerSpec<*, *>)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(MessageProducerSpec<*, *>)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
fun integrationFlow(producerSpec: MessageProducerSpec<*, *>,
|
||||
flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(producerSpec), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(producerSpec), flow)
|
||||
|
||||
/**
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] -
|
||||
* `IntegrationFlows.from(IntegrationFlow)` factory method.
|
||||
* Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] -
|
||||
* `IntegrationFlow.from(IntegrationFlow)` factory method.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 5.5.8
|
||||
*/
|
||||
fun integrationFlow(sourceFlow: IntegrationFlow, flow: KotlinIntegrationFlowDefinition.() -> Unit) =
|
||||
buildIntegrationFlow(IntegrationFlows.from(sourceFlow), flow)
|
||||
buildIntegrationFlow(IntegrationFlow.from(sourceFlow), flow)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 the original author or authors.
|
||||
* Copyright 2021-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.
|
||||
@@ -31,7 +31,6 @@ import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
@@ -124,14 +123,14 @@ public class IntegrationFlowCompositionTests {
|
||||
IntegrationFlow startFlow = f -> f.handle(m -> { });
|
||||
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> IntegrationFlows.from(startFlow))
|
||||
.isThrownBy(() -> IntegrationFlow.from(startFlow))
|
||||
.withMessageContaining("must be declared as a bean in the application context");
|
||||
|
||||
IntegrationFlowContext.IntegrationFlowRegistration startRegistration =
|
||||
this.integrationFlowContext.registration(startFlow).register();
|
||||
|
||||
assertThatExceptionOfType(BeanCreationException.class)
|
||||
.isThrownBy(() -> IntegrationFlows.from(startRegistration.getIntegrationFlow()))
|
||||
.isThrownBy(() -> IntegrationFlow.from(startRegistration.getIntegrationFlow()))
|
||||
.withMessageContaining("The 'IntegrationFlow' to start from must end with " +
|
||||
"a 'MessageChannel' or reply-producing endpoint");
|
||||
|
||||
@@ -175,14 +174,14 @@ public class IntegrationFlowCompositionTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow templateSourceFlow() {
|
||||
return IntegrationFlows.fromSupplier(() -> "test data")
|
||||
return IntegrationFlow.fromSupplier(() -> "test data")
|
||||
.channel("sourceChannel")
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
IntegrationFlow compositionMainFlow(IntegrationFlow templateSourceFlow) {
|
||||
return IntegrationFlows.from(templateSourceFlow)
|
||||
return IntegrationFlow.from(templateSourceFlow)
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(c -> c.queue("compositionMainFlowResult"))
|
||||
.get();
|
||||
@@ -196,7 +195,7 @@ public class IntegrationFlowCompositionTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow middleFlow(IntegrationFlow firstFlow, IntegrationFlow lastFlow) {
|
||||
return IntegrationFlows.from(firstFlow)
|
||||
return IntegrationFlow.from(firstFlow)
|
||||
.<String, String>transform(p -> p + ", and middle flow")
|
||||
.to(lastFlow);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -39,7 +39,6 @@ import org.springframework.integration.aggregator.HeaderAttributeCorrelationStra
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannelSpec;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
@@ -249,7 +248,7 @@ public class CorrelationHandlerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow splitAggregateFlow() {
|
||||
return IntegrationFlows.from("splitAggregateInput", true)
|
||||
return IntegrationFlow.from("splitAggregateInput", true)
|
||||
.transform(Transformers.toJson(ObjectToJsonTransformer.ResultType.NODE))
|
||||
.split((splitter) -> splitter
|
||||
.discardFlow((subFlow) -> subFlow.channel((c) -> c.queue("discardChannel"))))
|
||||
@@ -312,7 +311,7 @@ public class CorrelationHandlerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow releaseBarrierFlow(MessageTriggerAction barrierTriggerAction) {
|
||||
return IntegrationFlows.from(releaseChannel())
|
||||
return IntegrationFlow.from(releaseChannel())
|
||||
.trigger(barrierTriggerAction,
|
||||
e -> e.poller(p -> p.fixedDelay(100)))
|
||||
.get();
|
||||
|
||||
@@ -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.
|
||||
@@ -60,7 +60,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
@@ -570,7 +569,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow supplierFlow() {
|
||||
return IntegrationFlows.fromSupplier(stringSupplier(), c -> c.id("stringSupplierEndpoint"))
|
||||
return IntegrationFlow.fromSupplier(stringSupplier(), c -> c.id("stringSupplierEndpoint"))
|
||||
.transform(toUpperCaseFunction())
|
||||
.channel("suppliedChannel")
|
||||
.get();
|
||||
@@ -602,7 +601,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow supplierFlow2() {
|
||||
return IntegrationFlows.fromSupplier(() -> "foo",
|
||||
return IntegrationFlow.fromSupplier(() -> "foo",
|
||||
c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1)))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel("suppliedChannel2")
|
||||
@@ -622,7 +621,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow controlBusFlow() {
|
||||
return IntegrationFlows.from(ControlBusGateway.class, (gateway) -> gateway.beanName("controlBusGateway"))
|
||||
return IntegrationFlow.from(ControlBusGateway.class, (gateway) -> gateway.beanName("controlBusGateway"))
|
||||
.controlBus((endpoint) -> endpoint.id("controlBus"))
|
||||
.get();
|
||||
}
|
||||
@@ -661,7 +660,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow2() {
|
||||
return IntegrationFlows.from(this.inputChannel)
|
||||
return IntegrationFlow.from(this.inputChannel)
|
||||
.filter(p -> p instanceof String, e -> e
|
||||
.id("filter")
|
||||
.discardFlow(df -> df
|
||||
@@ -715,7 +714,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow wireTapFlow1() {
|
||||
return IntegrationFlows.from("tappedChannel1")
|
||||
return IntegrationFlow.from("tappedChannel1")
|
||||
.wireTap("tapChannel", wt -> wt.selector(m -> m.getPayload().equals("foo")))
|
||||
.handle(new ReactiveMessageHandlerAdapter((message) -> Mono.just(message).log().then()))
|
||||
.get();
|
||||
@@ -738,7 +737,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow wireTapFlow4() {
|
||||
return IntegrationFlows.from("tappedChannel4")
|
||||
return IntegrationFlow.from("tappedChannel4")
|
||||
.wireTap(tapChannel())
|
||||
.channel("nullChannel")
|
||||
.get();
|
||||
@@ -792,14 +791,14 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow bridgeFlow() {
|
||||
return IntegrationFlows.from(MessageChannels.queue("bridgeFlowInput"))
|
||||
return IntegrationFlow.from(MessageChannels.queue("bridgeFlowInput"))
|
||||
.channel(MessageChannels.queue("bridgeFlowOutput"))
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow bridgeFlow2() {
|
||||
return IntegrationFlows.from("bridgeFlow2Input")
|
||||
return IntegrationFlow.from("bridgeFlow2Input")
|
||||
.bridge(c -> c.autoStartup(false).id("bridge"))
|
||||
.fixedSubscriberChannel()
|
||||
.delay("delayer", d -> d
|
||||
@@ -817,7 +816,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow claimCheckFlow() {
|
||||
return IntegrationFlows.from("claimCheckInput")
|
||||
return IntegrationFlow.from("claimCheckInput")
|
||||
.claimCheckIn(this.messageStore())
|
||||
.claimCheckOut(this.messageStore())
|
||||
.get();
|
||||
@@ -851,14 +850,14 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow methodInvokingFlow() {
|
||||
return IntegrationFlows.from("methodInvokingInput")
|
||||
return IntegrationFlow.from("methodInvokingInput")
|
||||
.handle(this.greetingService)
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow lambdasFlow() {
|
||||
return IntegrationFlows.from("lambdasInput")
|
||||
return IntegrationFlow.from("lambdasInput")
|
||||
.filter(String.class, "World"::equals)
|
||||
.transform(String.class, "Hello "::concat)
|
||||
.get();
|
||||
@@ -866,7 +865,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow errorRecovererFlow() {
|
||||
return IntegrationFlows.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
|
||||
return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
|
||||
.<Object>handle((p, h) -> {
|
||||
throw new RuntimeException("intentional");
|
||||
},
|
||||
@@ -888,7 +887,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow recoveryFlow() {
|
||||
return IntegrationFlows.from(recoveryChannel())
|
||||
return IntegrationFlow.from(recoveryChannel())
|
||||
.<MessagingException, Message<?>>transform(MessagingException::getFailedMessage)
|
||||
.get();
|
||||
|
||||
@@ -896,7 +895,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow dedicatedPollingThreadFlow() {
|
||||
return IntegrationFlows.from(MessageChannels.queue("dedicatedQueueChannel"))
|
||||
return IntegrationFlow.from(MessageChannels.queue("dedicatedQueueChannel"))
|
||||
.bridge(e -> e
|
||||
.poller(Pollers.fixedDelay(0).receiveTimeout(-1))
|
||||
.taskScheduler(dedicatedTaskScheduler()))
|
||||
@@ -912,7 +911,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flowWithNullChannel() {
|
||||
return IntegrationFlows.from("flowWithNullChannelInput")
|
||||
return IntegrationFlow.from("flowWithNullChannelInput")
|
||||
.nullChannel();
|
||||
}
|
||||
|
||||
@@ -948,7 +947,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow globalErrorChannelResolutionFlow(@Qualifier("taskScheduler") TaskExecutor taskExecutor) {
|
||||
return IntegrationFlows.from(Consumer.class,
|
||||
return IntegrationFlow.from(Consumer.class,
|
||||
(gateway) -> gateway.beanName("globalErrorChannelResolutionFunction"))
|
||||
.channel(c -> c.executor(taskExecutor))
|
||||
.handle((p, h) -> {
|
||||
@@ -969,7 +968,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow interceptorFlow(List<String> outputStringList) {
|
||||
return IntegrationFlows.from("interceptorChannelIn")
|
||||
return IntegrationFlow.from("interceptorChannelIn")
|
||||
.intercept(new ChannelInterceptor() {
|
||||
|
||||
@Override
|
||||
@@ -1029,7 +1028,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow wrongLastComponent() {
|
||||
return IntegrationFlows.from(MessageChannels.direct())
|
||||
return IntegrationFlow.from(MessageChannels.direct())
|
||||
.fixedSubscriberChannel()
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,6 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowAdapter;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.handler.LoggingHandler;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
@@ -132,7 +131,7 @@ public class FlowServiceTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow subFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from("processChannel")
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel("replyChannel")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2020 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.
|
||||
@@ -39,7 +39,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
@@ -174,7 +173,7 @@ public class GatewayDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow gatewayFlow() {
|
||||
return IntegrationFlows.from("gatewayInput")
|
||||
return IntegrationFlow.from("gatewayInput")
|
||||
.gateway("gatewayRequest", g -> g.errorChannel("gatewayError").replyTimeout(10L))
|
||||
.gateway((f) -> f.transform("From Gateway SubFlow: "::concat))
|
||||
.get();
|
||||
@@ -182,7 +181,7 @@ public class GatewayDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow gatewayRequestFlow() {
|
||||
return IntegrationFlows.from("gatewayRequest")
|
||||
return IntegrationFlow.from("gatewayRequest")
|
||||
.filter("foo"::equals, (f) -> f.throwExceptionOnRejection(true))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.get();
|
||||
@@ -207,7 +206,7 @@ public class GatewayDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow functionGateway() {
|
||||
return IntegrationFlows.from(MessageFunction.class,
|
||||
return IntegrationFlow.from(MessageFunction.class,
|
||||
(gateway) -> gateway
|
||||
.header("gatewayMethod", MethodArgsHolder::getMethod)
|
||||
.header("gatewayArgs", MethodArgsHolder::getArgs)
|
||||
@@ -219,7 +218,7 @@ public class GatewayDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow routingGatewayFlow() {
|
||||
return IntegrationFlows.from(RoutingGateway.class,
|
||||
return IntegrationFlow.from(RoutingGateway.class,
|
||||
(gateway) -> gateway.beanName("routingGateway").header("gatewayMethod", MethodArgsHolder::getMethod))
|
||||
.route(Message.class, (message) ->
|
||||
message.getHeaders().get("gatewayMethod", Method.class).getName(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -62,7 +62,6 @@ import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowAdapter;
|
||||
import org.springframework.integration.dsl.IntegrationFlowBuilder;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.MessageProducerSpec;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
@@ -131,7 +130,7 @@ public class ManualFlowTests {
|
||||
};
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("channel");
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(producer);
|
||||
IntegrationFlowBuilder flowBuilder = IntegrationFlow.from(producer);
|
||||
|
||||
BridgeHandler bridgeHandler = new BridgeHandler();
|
||||
bridgeHandler.setBeanName("bridge");
|
||||
@@ -175,7 +174,7 @@ public class ManualFlowTests {
|
||||
}
|
||||
MyProducerSpec spec = new MyProducerSpec(new MyProducer());
|
||||
QueueChannel channel = new QueueChannel();
|
||||
IntegrationFlow flow = IntegrationFlows.from(spec.id("fooChannel"))
|
||||
IntegrationFlow flow = IntegrationFlow.from(spec.id("fooChannel"))
|
||||
.channel(channel)
|
||||
.get();
|
||||
IntegrationFlowRegistration flowRegistration = this.integrationFlowContext.registration(flow).register();
|
||||
@@ -396,7 +395,7 @@ public class ManualFlowTests {
|
||||
|
||||
QueueChannel resultChannel = new QueueChannel();
|
||||
|
||||
IntegrationFlow integrationFlow = IntegrationFlows
|
||||
IntegrationFlow integrationFlow = IntegrationFlow
|
||||
.from(messageFlux)
|
||||
.<Integer, Boolean>route(p -> p % 2 == 0, m -> m
|
||||
.subFlowMapping(true, sf -> sf.<Integer, String>transform(em -> "even:" + em))
|
||||
@@ -426,7 +425,7 @@ public class ManualFlowTests {
|
||||
String testId = "testId";
|
||||
|
||||
StandardIntegrationFlow testFlow =
|
||||
IntegrationFlows.from(Supplier.class)
|
||||
IntegrationFlow.from(Supplier.class)
|
||||
.get();
|
||||
|
||||
IntegrationFlowRegistration flowRegistration =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -43,7 +43,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
@@ -173,7 +172,7 @@ public class ReactiveStreamsTests {
|
||||
QueueChannel resultChannel = new QueueChannel();
|
||||
|
||||
IntegrationFlow integrationFlow =
|
||||
IntegrationFlows.from(messageFlux)
|
||||
IntegrationFlow.from(messageFlux)
|
||||
.<Integer, Integer>transform(p -> p * 2)
|
||||
.channel(resultChannel)
|
||||
.get();
|
||||
@@ -250,7 +249,7 @@ public class ReactiveStreamsTests {
|
||||
|
||||
@Bean
|
||||
public Publisher<Message<String>> reactiveFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(() -> new GenericMessage<>("a,b,c,d,e,f"),
|
||||
e -> e.poller(p -> p.trigger(ctx -> this.invoked.getAndSet(true) ? null : new Date()))
|
||||
.id("reactiveStreamsMessageSource"))
|
||||
@@ -261,7 +260,7 @@ public class ReactiveStreamsTests {
|
||||
|
||||
@Bean
|
||||
public Publisher<Message<Integer>> pollableReactiveFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from("inputChannel")
|
||||
.split(s -> s.delimiters(","))
|
||||
.<String, Integer>transform(Integer::parseInt,
|
||||
@@ -273,7 +272,7 @@ public class ReactiveStreamsTests {
|
||||
|
||||
@Bean
|
||||
public Publisher<Message<String>> singleChannelFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(MessageChannels.direct("singleChannel"))
|
||||
.log()
|
||||
.toReactivePublisher();
|
||||
@@ -281,7 +280,7 @@ public class ReactiveStreamsTests {
|
||||
|
||||
@Bean
|
||||
public Publisher<Message<String>> fixedSubscriberChannelFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from("fixedSubscriberChannel", true)
|
||||
.log()
|
||||
.toReactivePublisher();
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.EnableMessageHistory;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.expression.FunctionExpression;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
@@ -639,7 +638,7 @@ public class RouterTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow routeFlow() {
|
||||
return IntegrationFlows.from("routerInput")
|
||||
return IntegrationFlow.from("routerInput")
|
||||
.<Integer, Boolean>route(p -> p % 2 == 0,
|
||||
m -> m.channelMapping(true, evenChannel())
|
||||
.subFlowMapping(false, f ->
|
||||
@@ -702,7 +701,7 @@ public class RouterTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow recipientListFlow() {
|
||||
return IntegrationFlows.from("recipientListInput")
|
||||
return IntegrationFlow.from("recipientListInput")
|
||||
.<String, String>transform(p -> p.replaceFirst("Payload", ""))
|
||||
.routeToRecipients(r -> r
|
||||
.recipient("foo-channel", "'foo' == payload")
|
||||
@@ -729,14 +728,14 @@ public class RouterTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow routeMethodInvocationFlow() {
|
||||
return IntegrationFlows.from("routerMethodInput")
|
||||
return IntegrationFlow.from("routerMethodInput")
|
||||
.route("routingTestBean", "routeMessage")
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow routeMethodInvocationFlow2() {
|
||||
return IntegrationFlows.from("routerMethod2Input")
|
||||
return IntegrationFlow.from("routerMethod2Input")
|
||||
.route(new RoutingTestBean())
|
||||
.get();
|
||||
}
|
||||
@@ -748,7 +747,7 @@ public class RouterTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow routeMultiMethodInvocationFlow() {
|
||||
return IntegrationFlows.from("routerMultiInput")
|
||||
return IntegrationFlow.from("routerMultiInput")
|
||||
.route(String.class, p -> p.equals("foo") || p.equals("bar")
|
||||
? new String[]{ "foo", "bar" }
|
||||
: null,
|
||||
@@ -918,7 +917,7 @@ public class RouterTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow propagateErrorFromGatherer(TaskExecutor taskExecutor) {
|
||||
return IntegrationFlows.from(Function.class)
|
||||
return IntegrationFlow.from(Function.class)
|
||||
.scatterGather(s -> s
|
||||
.recipientFlow(subFlow -> subFlow
|
||||
.channel(c -> c.executor(taskExecutor))
|
||||
|
||||
@@ -38,7 +38,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.codec.Codec;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
@@ -288,7 +287,7 @@ public class TransformerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow enricherFlow() {
|
||||
return IntegrationFlows.from("enricherInput", true)
|
||||
return IntegrationFlow.from("enricherInput", true)
|
||||
.enrich(e -> e.requestChannel("enrichChannel")
|
||||
.errorChannel(enricherErrorChannel())
|
||||
.requestPayloadExpression("payload")
|
||||
@@ -303,7 +302,7 @@ public class TransformerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow enricherFlow2() {
|
||||
return IntegrationFlows.from("enricherInput2", true)
|
||||
return IntegrationFlow.from("enricherInput2", true)
|
||||
.enrich(e -> e.requestChannel("enrichChannel")
|
||||
.requestPayloadExpression("payload")
|
||||
.shouldClonePayload(false)
|
||||
@@ -315,7 +314,7 @@ public class TransformerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow enricherFlow3() {
|
||||
return IntegrationFlows.from("enricherInput3", true)
|
||||
return IntegrationFlow.from("enricherInput3", true)
|
||||
.enrich(e -> e.requestChannel("enrichChannel")
|
||||
.requestPayload(Message::getPayload)
|
||||
.shouldClonePayload(false)
|
||||
@@ -325,7 +324,7 @@ public class TransformerTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow enrichFlow() {
|
||||
return IntegrationFlows.from("enrichChannel")
|
||||
return IntegrationFlow.from("enrichChannel")
|
||||
.<TestPojo, Map<?, ?>>transform(p -> {
|
||||
if ("junk".equals(p.getName())) {
|
||||
throw new RuntimeException("intentional");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 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.
|
||||
@@ -35,7 +35,6 @@ import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -108,7 +107,7 @@ public class ContentTypeConversionTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow serviceFlow() {
|
||||
return IntegrationFlows.from(ServiceGateway.class)
|
||||
return IntegrationFlow.from(ServiceGateway.class)
|
||||
.channel("serviceChannel")
|
||||
.handle(this)
|
||||
.get();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -42,7 +42,6 @@ import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.endpoint.AbstractMessageSource;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
@@ -355,7 +354,7 @@ public class MicrometerMetricsTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow gatesFlow() {
|
||||
return IntegrationFlows.from(Gate.class)
|
||||
return IntegrationFlow.from(Gate.class)
|
||||
.nullChannel();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2020 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.
|
||||
@@ -33,7 +33,6 @@ import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.test.condition.LogLevels;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.transformer.support.AvroHeaders;
|
||||
@@ -166,7 +165,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow1() {
|
||||
return IntegrationFlows.from(in1())
|
||||
return IntegrationFlow.from(in1())
|
||||
.transform(new SimpleToAvroTransformer())
|
||||
.wireTap(tapped())
|
||||
.transform(fromTransformer())
|
||||
@@ -177,7 +176,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow2() {
|
||||
return IntegrationFlows.from(in2())
|
||||
return IntegrationFlow.from(in2())
|
||||
.transform(new SimpleToAvroTransformer())
|
||||
.wireTap(tapped())
|
||||
.enrichHeaders(h -> h.header(AvroHeaders.TYPE, AvroTestClass2.class, true))
|
||||
@@ -189,7 +188,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow3() {
|
||||
return IntegrationFlows.from(in3())
|
||||
return IntegrationFlow.from(in3())
|
||||
.transform(new SimpleToAvroTransformer())
|
||||
.wireTap(tapped())
|
||||
.enrichHeaders(h -> h.header(AvroHeaders.TYPE, AvroTestClass2.class.getName(), true))
|
||||
@@ -201,7 +200,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow4() {
|
||||
return IntegrationFlows.from(in4())
|
||||
return IntegrationFlow.from(in4())
|
||||
.transform(new SimpleToAvroTransformer())
|
||||
.wireTap(tapped())
|
||||
.enrichHeaders(h -> h.header(AvroHeaders.TYPE, null, true)
|
||||
@@ -214,7 +213,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow5() {
|
||||
return IntegrationFlows.from(in5())
|
||||
return IntegrationFlow.from(in5())
|
||||
.transform(new SimpleToAvroTransformer().typeExpression("'avroTest'"))
|
||||
.wireTap(tapped())
|
||||
.transform(new SimpleFromAvroTransformer(AvroTestClass1.class)
|
||||
@@ -227,7 +226,7 @@ public class AvroTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow6() {
|
||||
return IntegrationFlows.from(in6())
|
||||
return IntegrationFlow.from(in6())
|
||||
.transform(new SimpleToAvroTransformer().typeExpression("'wontFindThisHeader'"))
|
||||
.wireTap(tapped())
|
||||
.transform(new SimpleFromAvroTransformer(AvroTestClass1.class)
|
||||
|
||||
@@ -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.
|
||||
@@ -34,7 +34,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.event.core.MessagingEvent;
|
||||
import org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer;
|
||||
@@ -132,7 +131,7 @@ public class IntegrationFlowEventsTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow3() {
|
||||
return IntegrationFlows.from("flow3Input")
|
||||
return IntegrationFlow.from("flow3Input")
|
||||
.handle(Integer.class, new GenericHandler<Integer>() {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@@ -172,7 +171,7 @@ public class IntegrationFlowEventsTests {
|
||||
ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
|
||||
producer.setEventTypes(TestApplicationEvent2.class);
|
||||
|
||||
return IntegrationFlows.from(producer)
|
||||
return IntegrationFlow.from(producer)
|
||||
.channel(resultsChannel())
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.metadata.MetadataStore;
|
||||
import org.springframework.integration.metadata.PropertiesPersistingMetadataStore;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -105,7 +104,7 @@ public class FeedDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow feedFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Feed.inboundAdapter(this.feedResource, "feedTest")
|
||||
.metadataStore(metadataStore())
|
||||
.preserveWireFeed(true),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -53,7 +53,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
@@ -248,7 +247,7 @@ public class FileTests {
|
||||
@Test
|
||||
public void testFileSplitterFlow() throws Exception {
|
||||
FileOutputStream file = new FileOutputStream(new File(tmpDir, "foo.tmp"));
|
||||
file.write(("HelloWorld\näöüß").getBytes(Charset.defaultCharset()));
|
||||
file.write(("HelloWorld\näöüß").getBytes(Charset.defaultCharset()));
|
||||
file.flush();
|
||||
file.close();
|
||||
|
||||
@@ -259,7 +258,7 @@ public class FileTests {
|
||||
receive = this.fileSplittingResultChannel.receive(10000);
|
||||
assertThat(receive).isNotNull(); //HelloWorld
|
||||
receive = this.fileSplittingResultChannel.receive(10000);
|
||||
assertThat(receive).isNotNull(); //äöüß
|
||||
assertThat(receive).isNotNull(); //äöüß
|
||||
receive = this.fileSplittingResultChannel.receive(10000);
|
||||
assertThat(receive).isNotNull();
|
||||
assertThat(receive.getPayload()).isInstanceOf(FileSplitter.FileMarker.class); // FileMarker.Mark.END
|
||||
@@ -337,7 +336,7 @@ public class FileTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileFlow1() {
|
||||
return IntegrationFlows.from("fileFlow1Input")
|
||||
return IntegrationFlow.from("fileFlow1Input")
|
||||
.handle(Files.outboundAdapter("'file://" + tmpDir.getAbsolutePath() + '\'')
|
||||
.fileNameGenerator(message -> null)
|
||||
.fileExistsMode(FileExistsMode.APPEND_NO_FLUSH)
|
||||
@@ -353,7 +352,7 @@ public class FileTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow tailFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Files.tailAdapter(new File(tmpDir, "TailTest"))
|
||||
.delay(500)
|
||||
.end(false)
|
||||
@@ -366,7 +365,7 @@ public class FileTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileReadingFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Files.inboundAdapter(tmpDir)
|
||||
.patternFilter("*.sitest")
|
||||
.useWatchService(true)
|
||||
@@ -390,7 +389,7 @@ public class FileTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileWritingFlow() {
|
||||
return IntegrationFlows.from("fileWritingInput")
|
||||
return IntegrationFlow.from("fileWritingInput")
|
||||
.enrichHeaders(h -> h.header(FileHeaders.FILENAME, "foo.write")
|
||||
.header("directory", new File(tmpDir, "fileWritingFlow")))
|
||||
.handle(Files.outboundGateway(m -> m.getHeaders().get("directory"))
|
||||
@@ -407,7 +406,7 @@ public class FileTests {
|
||||
new ExpressionFileListFilter<>(new FunctionExpression<File>(f -> "foo.tmp".equals(f.getName())));
|
||||
fileExpressionFileListFilter.setBeanFactory(beanFactory);
|
||||
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Files.inboundAdapter(tmpDir)
|
||||
.filter(new ChainFileListFilter<File>()
|
||||
.addFilter(new AcceptOnceFileListFilter<>())
|
||||
@@ -441,7 +440,7 @@ public class FileTests {
|
||||
|
||||
void pollDirectories(File... directories) {
|
||||
for (File directory : directories) {
|
||||
StandardIntegrationFlow integrationFlow = IntegrationFlows
|
||||
StandardIntegrationFlow integrationFlow = IntegrationFlow
|
||||
.from(Files.inboundAdapter(directory).recursive(true),
|
||||
e -> e.poller(p -> p.fixedDelay(1000))
|
||||
.id(directory.getName() + ".adapter"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2020 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.
|
||||
@@ -43,7 +43,6 @@ import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.config.IntegrationManagementConfigurer;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
@@ -91,7 +90,7 @@ public class FtpTests extends FtpTestSupport {
|
||||
public void testFtpInboundFlow() throws IOException {
|
||||
QueueChannel out = new QueueChannel();
|
||||
DirectoryScanner scanner = new DefaultDirectoryScanner();
|
||||
IntegrationFlow flow = IntegrationFlows.from(Ftp.inboundAdapter(sessionFactory())
|
||||
IntegrationFlow flow = IntegrationFlow.from(Ftp.inboundAdapter(sessionFactory())
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("ftpSource")
|
||||
.maxFetchSize(10)
|
||||
@@ -150,7 +149,7 @@ public class FtpTests extends FtpTestSupport {
|
||||
@Test
|
||||
public void testFtpInboundStreamFlow() throws Exception {
|
||||
QueueChannel out = new QueueChannel();
|
||||
StandardIntegrationFlow flow = IntegrationFlows.from(
|
||||
StandardIntegrationFlow flow = IntegrationFlow.from(
|
||||
Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sessionFactory()))
|
||||
.remoteDirectory("ftpSource")
|
||||
.maxFetchSize(11)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -41,7 +41,6 @@ import org.springframework.integration.StaticMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
@@ -324,7 +323,7 @@ public class RotatingServersTests extends FtpTestSupport {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Ftp.inboundAdapter(sf())
|
||||
return IntegrationFlow.from(Ftp.inboundAdapter(sf())
|
||||
.filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.localDirectory(localDir())
|
||||
.remoteDirectory("."),
|
||||
@@ -360,7 +359,7 @@ public class RotatingServersTests extends FtpTestSupport {
|
||||
@Override
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Ftp.inboundAdapter(sf())
|
||||
return IntegrationFlow.from(Ftp.inboundAdapter(sf())
|
||||
.filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.localDirectory(new File(TMP_DIR, "variable"))
|
||||
.localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root")
|
||||
@@ -378,7 +377,7 @@ public class RotatingServersTests extends FtpTestSupport {
|
||||
@Override
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf()))
|
||||
return IntegrationFlow.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf()))
|
||||
.filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.remoteDirectory("."),
|
||||
e -> e.poller(Pollers.fixedDelay(1).advice(advice())))
|
||||
@@ -404,7 +403,7 @@ public class RotatingServersTests extends FtpTestSupport {
|
||||
@Override
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf()))
|
||||
return IntegrationFlow.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf()))
|
||||
.filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.remoteDirectory(".")
|
||||
.maxFetchSize(1),
|
||||
|
||||
@@ -44,7 +44,6 @@ import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandlingException;
|
||||
@@ -287,7 +286,7 @@ public class GraphQlMessageHandlerTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow graphqlQueryMessageHandlerFlow(GraphQlMessageHandler handler) {
|
||||
return IntegrationFlows.from(MessageChannels.flux("inputChannel"))
|
||||
return IntegrationFlow.from(MessageChannels.flux("inputChannel"))
|
||||
.handle(handler)
|
||||
.channel(c -> c.flux("resultChannel"))
|
||||
.get();
|
||||
|
||||
@@ -48,7 +48,6 @@ import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.http.multipart.UploadedMultipartFile;
|
||||
@@ -141,7 +140,7 @@ public class HttpDslTests {
|
||||
@Test
|
||||
public void testDynamicHttpEndpoint() throws Exception {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(Http.inboundGateway("/dynamic")
|
||||
IntegrationFlow.from(Http.inboundGateway("/dynamic")
|
||||
.requestMapping(r -> r.params("name"))
|
||||
.payloadExpression("#requestParams.name[0]"))
|
||||
.<String, String>transform(String::toLowerCase)
|
||||
@@ -214,7 +213,7 @@ public class HttpDslTests {
|
||||
@Test
|
||||
public void testValidation() throws Exception {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
Http.inboundChannelAdapter("/validation")
|
||||
.requestMapping((mapping) -> mapping
|
||||
.methods(HttpMethod.POST)
|
||||
@@ -241,7 +240,7 @@ public class HttpDslTests {
|
||||
@Test
|
||||
public void testBadRequest() throws Exception {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
Http.inboundGateway("/badRequest")
|
||||
.errorChannel((message, timeout) -> {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST,
|
||||
@@ -266,7 +265,7 @@ public class HttpDslTests {
|
||||
@Test
|
||||
public void testErrorChannelFlow() throws Exception {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
Http.inboundGateway("/errorFlow")
|
||||
.errorChannel(new FixedSubscriberChannel(
|
||||
new AbstractReplyProducingMessageHandler() {
|
||||
@@ -342,7 +341,7 @@ public class HttpDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow httpInternalServiceFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Http.inboundGateway("/service/internal")
|
||||
.requestMapping(r -> r.params("name"))
|
||||
.payloadExpression("#requestParams.name"))
|
||||
@@ -360,7 +359,7 @@ public class HttpDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow httpProxyFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(httpService())
|
||||
.handle(Http.outboundGateway("/service/internal?{params}")
|
||||
.uriVariable("params", "payload")
|
||||
@@ -381,7 +380,7 @@ public class HttpDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow multiPartFilesFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Http.inboundChannelAdapter("/multiPartFiles")
|
||||
.headerFunction("contentLength", (entity) -> entity.getHeaders().getContentLength()))
|
||||
.channel((c) -> c.queue("multiPartFilesChannel"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -39,7 +39,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
@@ -198,7 +197,7 @@ public class IpIntegrationTests {
|
||||
|
||||
@Test
|
||||
void testCloseStream() throws InterruptedException {
|
||||
IntegrationFlow server = IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(0)
|
||||
IntegrationFlow server = IntegrationFlow.from(Tcp.inboundGateway(Tcp.netServer(0)
|
||||
.deserializer(new ByteArrayRawSerializer())))
|
||||
.<byte[], String>transform(p -> "reply:" + new String(p).toUpperCase())
|
||||
.get();
|
||||
@@ -218,7 +217,7 @@ public class IpIntegrationTests {
|
||||
.id("streamCloseServer")
|
||||
.register();
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
IntegrationFlow client = IntegrationFlows.from(MessageChannels.direct())
|
||||
IntegrationFlow client = IntegrationFlow.from(MessageChannels.direct())
|
||||
.handle(Tcp.outboundGateway(Tcp.netClient("localhost", port.get())
|
||||
.singleUseConnections(true)
|
||||
.serializer(new ByteArrayRawSerializer()))
|
||||
@@ -258,7 +257,7 @@ public class IpIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow inTcpGateway() {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
Tcp.inboundGateway(server1())
|
||||
.replyTimeout(1)
|
||||
.errorOnTimeout(true)
|
||||
@@ -296,7 +295,7 @@ public class IpIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow inUdpAdapter() {
|
||||
return IntegrationFlows.from(Udp.inboundAdapter(0))
|
||||
return IntegrationFlow.from(Udp.inboundAdapter(0))
|
||||
.channel(udpIn())
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -46,7 +46,6 @@ import org.springframework.integration.config.GlobalChannelInterceptor;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.endpoint.MethodInvokingMessageSource;
|
||||
@@ -325,7 +324,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsInboundFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jms.inboundAdapter(amqFactory).destination("jmsInbound"))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(this.jmsOutboundInboundReplyChannel())
|
||||
@@ -352,7 +351,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsMessageDrivenFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jms.messageDrivenChannelAdapter(amqFactory,
|
||||
DefaultMessageListenerContainer.class)
|
||||
.outputChannel(jmsMessageDrivenInputChannel())
|
||||
@@ -385,7 +384,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsMessageDrivenFlowWithContainer() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jms.messageDrivenChannelAdapter(
|
||||
Jms.container(amqFactory, "containerSpecDestination")
|
||||
.pubSubDomain(false)
|
||||
@@ -406,7 +405,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsInboundGatewayFlow() {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
Jms.inboundGateway(amqFactory)
|
||||
.requestChannel(jmsInboundGatewayInputChannel())
|
||||
.replyTimeout(1)
|
||||
@@ -451,7 +450,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsMessageDrivenRedeliveryFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jms.messageDrivenChannelAdapter(amqFactory)
|
||||
.errorChannel("errorChannelForRedelivery")
|
||||
.destination("jmsMessageDrivenRedelivery")
|
||||
@@ -473,7 +472,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow errorHandlingFlow() {
|
||||
return IntegrationFlows.from("errorChannelForRedelivery")
|
||||
return IntegrationFlow.from("errorChannelForRedelivery")
|
||||
.handle(m -> {
|
||||
MessagingException exception = (MessagingException) m.getPayload();
|
||||
redeliveryLatch().countDown();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -30,7 +30,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.jmx.support.MBeanServerFactoryBean;
|
||||
@@ -63,7 +62,7 @@ public class DslMBeanTests {
|
||||
assertThat(query).hasSize(0);
|
||||
|
||||
IntegrationFlow dynamicFlow =
|
||||
IntegrationFlows.fromSupplier(() -> "foo", e -> e.poller(p -> p.fixedDelay(1000)))
|
||||
IntegrationFlow.fromSupplier(() -> "foo", e -> e.poller(p -> p.fixedDelay(1000)))
|
||||
.channel("channelTwo")
|
||||
.nullChannel();
|
||||
|
||||
@@ -105,7 +104,7 @@ public class DslMBeanTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow staticFlow() {
|
||||
return IntegrationFlows.from("channelOne")
|
||||
return IntegrationFlow.from("channelOne")
|
||||
.nullChannel();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -34,7 +34,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.jpa.support.PersistMode;
|
||||
import org.springframework.integration.jpa.test.entity.Gender;
|
||||
import org.springframework.integration.jpa.test.entity.StudentDomain;
|
||||
@@ -215,7 +214,7 @@ public class JpaTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pollingAdapterFlow(EntityManagerFactory entityManagerFactory) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jpa.inboundAdapter(entityManagerFactory)
|
||||
.entityClass(StudentDomain.class)
|
||||
.maxResults(1)
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.springframework.integration.channel.BroadcastCapableChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.kafka.channel.PollableKafkaChannel;
|
||||
import org.springframework.integration.kafka.inbound.KafkaErrorSendingMessageRecoverer;
|
||||
@@ -301,7 +300,7 @@ public class KafkaDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow topic1ListenerFromKafkaFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.messageDrivenChannelAdapter(consumerFactory(),
|
||||
KafkaMessageDrivenChannelAdapter.ListenerMode.record, TEST_TOPIC1)
|
||||
.configureListenerContainer(c ->
|
||||
@@ -331,7 +330,7 @@ public class KafkaDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow topic2ListenerFromKafkaFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka
|
||||
.messageDrivenChannelAdapter(kafkaListenerContainerFactory().createContainer(TEST_TOPIC2),
|
||||
KafkaMessageDrivenChannelAdapter.ListenerMode.record))
|
||||
@@ -397,7 +396,7 @@ public class KafkaDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sourceFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.inboundChannelAdapter(consumerFactory(), new ConsumerProperties(TEST_TOPIC3)),
|
||||
e -> e.poller(Pollers.fixedDelay(100)))
|
||||
.handle(p -> {
|
||||
@@ -410,7 +409,7 @@ public class KafkaDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow outboundGateFlow() {
|
||||
return IntegrationFlows.from(Gate.class)
|
||||
return IntegrationFlow.from(Gate.class)
|
||||
.handle(Kafka.outboundGateway(producerFactory(), replyContainer())
|
||||
.flushExpression("true")
|
||||
.sync(true)
|
||||
@@ -440,7 +439,7 @@ public class KafkaDslTests {
|
||||
ConcurrentKafkaListenerContainerFactory<Integer, String> containerFactory,
|
||||
KafkaMessageSource<?, ?> channelSource) {
|
||||
|
||||
return IntegrationFlows.from(topic6Channel(template, containerFactory))
|
||||
return IntegrationFlow.from(topic6Channel(template, containerFactory))
|
||||
.publishSubscribeChannel(pubSub(template, containerFactory), channel -> channel
|
||||
.subscribe(f -> f.channel(
|
||||
Kafka.pollableChannel(template, channelSource).id("topic8Channel")))
|
||||
@@ -478,7 +477,7 @@ public class KafkaDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow serverGateway() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.inboundGateway(consumerFactory(), containerProperties(),
|
||||
producerFactory())
|
||||
.configureListenerContainer(container -> container.errorHandler(eh())))
|
||||
@@ -495,7 +494,7 @@ public class KafkaDslTests {
|
||||
IntegrationFlow withRecoveringErrorHandler() {
|
||||
ContainerProperties props = containerProperties();
|
||||
props.setGroupId("wreh");
|
||||
return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(consumerFactory(), props)
|
||||
return IntegrationFlow.from(Kafka.messageDrivenChannelAdapter(consumerFactory(), props)
|
||||
.configureListenerContainer(container -> {
|
||||
container.errorHandler(recoveringErrorHandler());
|
||||
}))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2021 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.
|
||||
@@ -43,7 +43,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.mail.ImapIdleChannelAdapter;
|
||||
import org.springframework.integration.mail.MailHeaders;
|
||||
@@ -203,7 +202,7 @@ public class MailTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sendMailFlow() {
|
||||
return IntegrationFlows.from("sendMailChannel")
|
||||
return IntegrationFlow.from("sendMailChannel")
|
||||
.enrichHeaders(Mail.headers()
|
||||
.subjectFunction(m -> "foo")
|
||||
.from("foo@bar")
|
||||
@@ -219,7 +218,7 @@ public class MailTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pop3MailFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Mail.pop3InboundAdapter("localhost", mailServer.getPop3().getPort(), "popuser", "pw")
|
||||
.javaMailProperties(p -> p.put("mail.debug", "false"))
|
||||
.autoCloseFolder(true)
|
||||
@@ -233,7 +232,7 @@ public class MailTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow imapMailFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Mail.imapInboundAdapter("imap://imapuser:pw@localhost:" + mailServer.getImap().getPort() + "/INBOX")
|
||||
.searchTermStrategy(this::fromAndNotSeenTerm)
|
||||
.userFlag("testSIUserFlag")
|
||||
@@ -248,7 +247,7 @@ public class MailTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow imapIdleFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Mail.imapIdleAdapter("imap://imapidleuser:pw@localhost:" + mailServer.getImap().getPort() + "/INBOX")
|
||||
.autoStartup(true)
|
||||
.searchTermStrategy(this::fromAndNotSeenTerm)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -37,7 +37,6 @@ import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||
import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.mongodb.Person;
|
||||
@@ -157,7 +156,7 @@ public class MongoDbChangeStreamMessageProducerTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow changeStreamFlow() {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
MongoDb.changeStreamInboundChannelAdapter(mongoTemplate())
|
||||
.domainType(Person.class)
|
||||
.collection("person")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -48,7 +48,6 @@ import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.mongodb.dsl.MongoDb;
|
||||
import org.springframework.integration.mongodb.rules.MongoDbAvailable;
|
||||
@@ -247,7 +246,7 @@ public class ReactiveMongoDbMessageSourceTests extends MongoDbAvailableTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pollingFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(MongoDb.reactiveInboundChannelAdapter(
|
||||
REACTIVE_MONGO_DATABASE_FACTORY, "{'name' : 'Oleg'}")
|
||||
.update(Update.update("name", "DONE"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -33,7 +33,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport;
|
||||
import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
|
||||
import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
|
||||
@@ -114,7 +113,7 @@ public class MqttDslTests implements MosquittoContainerTest {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow mqttInFlow() {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
new MqttPahoMessageDrivenChannelAdapter("jmxTestIn",
|
||||
pahoClientFactory(), "jmxTests"))
|
||||
.channel(c -> c.queue("fromMqttChannel"))
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.mqtt.event.MqttSubscribedEvent;
|
||||
import org.springframework.integration.mqtt.inbound.Mqttv5PahoMessageDrivenChannelAdapter;
|
||||
import org.springframework.integration.mqtt.outbound.Mqttv5PahoMessageHandler;
|
||||
@@ -126,7 +125,7 @@ public class Mqttv5BackToBackAutomaticReconnectTests implements MosquittoContain
|
||||
new Mqttv5PahoMessageDrivenChannelAdapter(mqttConnectOptions(), "mqttv5SIin", "siTest");
|
||||
messageProducer.setPayloadType(String.class);
|
||||
|
||||
return IntegrationFlows.from(messageProducer)
|
||||
return IntegrationFlow.from(messageProducer)
|
||||
.channel(c -> c.queue("fromMqttChannel"))
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.acks.SimpleAcknowledgment;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.mqtt.event.MqttIntegrationEvent;
|
||||
import org.springframework.integration.mqtt.event.MqttMessageDeliveredEvent;
|
||||
import org.springframework.integration.mqtt.event.MqttMessageSentEvent;
|
||||
@@ -178,7 +177,7 @@ public class Mqttv5BackToBackTests implements MosquittoContainerTest {
|
||||
messageProducer.setMessageConverter(mqttStringToBytesConverter());
|
||||
messageProducer.setManualAcks(true);
|
||||
|
||||
return IntegrationFlows.from(messageProducer)
|
||||
return IntegrationFlow.from(messageProducer)
|
||||
.channel(c -> c.queue("fromMqttChannel"))
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-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.
|
||||
@@ -35,7 +35,6 @@ import org.springframework.data.relational.core.query.Criteria;
|
||||
import org.springframework.data.relational.core.query.Query;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.r2dbc.config.R2dbcDatabaseConfiguration;
|
||||
import org.springframework.integration.r2dbc.entity.Person;
|
||||
@@ -102,7 +101,7 @@ public class R2dbcDslTests {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow r2dbcDslFlow(R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(R2dbc.inboundChannelAdapter(r2dbcEntityTemplate,
|
||||
(selectCreator) ->
|
||||
selectCreator.createSelect("person")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 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.
|
||||
@@ -29,7 +29,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.rsocket.ClientRSocketConnector;
|
||||
import org.springframework.integration.rsocket.RSocketInteractionModel;
|
||||
@@ -129,7 +128,7 @@ public class RSocketDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow rsocketUpperCaseRequestFlow(ClientRSocketConnector clientRSocketConnector) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Function.class)
|
||||
.handle(RSockets.outboundGateway(message ->
|
||||
message.getHeaders().getOrDefault("route", "/uppercase"))
|
||||
@@ -145,7 +144,7 @@ public class RSocketDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow rsocketUpperCaseFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(RSockets.inboundGateway("/uppercase")
|
||||
.interactionModels(RSocketInteractionModel.requestChannel))
|
||||
.<Flux<String>, Flux<String>>transform((flux) -> flux.map(String::toUpperCase))
|
||||
@@ -154,7 +153,7 @@ public class RSocketDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow rsocketUpperCaseWholeFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(RSockets.inboundGateway("/uppercaseWhole")
|
||||
.interactionModels(RSocketInteractionModel.requestChannel)
|
||||
.decodeFluxAsUnit(true))
|
||||
@@ -164,7 +163,7 @@ public class RSocketDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow rsocketLowerCaseFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(RSockets.inboundGateway("/lowercase"))
|
||||
.<Flux<String>, Flux<String>>transform((flux) -> flux.map(String::toLowerCase))
|
||||
.get();
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.integration.channel.FluxMessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.expression.FunctionExpression;
|
||||
import org.springframework.integration.rsocket.ClientRSocketConnector;
|
||||
@@ -501,7 +500,7 @@ public class RSocketOutboundGatewayIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow rsocketOutboundFlow() {
|
||||
return IntegrationFlows.from(MessageChannels.flux("inputChannel"))
|
||||
return IntegrationFlow.from(MessageChannels.flux("inputChannel"))
|
||||
.handle(rsocketOutboundGateway())
|
||||
.channel(c -> c.flux("resultChannel"))
|
||||
.get();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 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.
|
||||
@@ -38,7 +38,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.channel.QueueChannelOperations;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -256,7 +255,7 @@ public class ScriptsTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow scriptPollingAdapter() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Scripts.messageSource("scripts/TestMessageSourceScript.rb"),
|
||||
e -> e.poller(p -> p.fixedDelay(100)))
|
||||
.channel(c -> c.queue("messageSourceChannel"))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2021 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.
|
||||
@@ -34,7 +34,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
@@ -72,7 +71,7 @@ public class SftpTests extends SftpTestSupport {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSftpInboundFlow() {
|
||||
QueueChannel out = new QueueChannel();
|
||||
IntegrationFlow flow = IntegrationFlows
|
||||
IntegrationFlow flow = IntegrationFlow
|
||||
.from(Sftp.inboundAdapter(sessionFactory())
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("sftpSource")
|
||||
@@ -104,7 +103,7 @@ public class SftpTests extends SftpTestSupport {
|
||||
@Test
|
||||
public void testSftpInboundStreamFlow() throws Exception {
|
||||
QueueChannel out = new QueueChannel();
|
||||
StandardIntegrationFlow flow = IntegrationFlows.from(
|
||||
StandardIntegrationFlow flow = IntegrationFlow.from(
|
||||
Sftp.inboundStreamingAdapter(new SftpRemoteFileTemplate(sessionFactory()))
|
||||
.remoteDirectory("sftpSource")
|
||||
.regexFilter(".*\\.txt$"),
|
||||
|
||||
@@ -42,7 +42,6 @@ import org.springframework.integration.config.EnableIntegrationManagement;
|
||||
import org.springframework.integration.config.IntegrationManagementConfigurer;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
@@ -118,7 +117,7 @@ public class SmbTests extends SmbTestSupport {
|
||||
public void testSmbInboundFlow() throws IOException {
|
||||
QueueChannel out = new QueueChannel();
|
||||
DirectoryScanner scanner = new DefaultDirectoryScanner();
|
||||
IntegrationFlow flow = IntegrationFlows.from(Smb.inboundAdapter(sessionFactory())
|
||||
IntegrationFlow flow = IntegrationFlow.from(Smb.inboundAdapter(sessionFactory())
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("smbSource")
|
||||
.maxFetchSize(10)
|
||||
@@ -163,7 +162,7 @@ public class SmbTests extends SmbTestSupport {
|
||||
@Test
|
||||
public void testSmbInboundStreamFlow() throws Exception {
|
||||
QueueChannel out = new QueueChannel();
|
||||
StandardIntegrationFlow flow = IntegrationFlows.from(
|
||||
StandardIntegrationFlow flow = IntegrationFlow.from(
|
||||
Smb.inboundStreamingAdapter(new SmbRemoteFileTemplate(sessionFactory()))
|
||||
.remoteDirectory("smbSource")
|
||||
.maxFetchSize(11)
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.PollerSpec;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.StandardIntegrationFlow;
|
||||
@@ -148,7 +147,7 @@ public class MockMessageSourceTests {
|
||||
@Test
|
||||
public void testMockMessageSourceDynamicFlow() {
|
||||
QueueChannel out = new QueueChannel();
|
||||
StandardIntegrationFlow flow = IntegrationFlows
|
||||
StandardIntegrationFlow flow = IntegrationFlow
|
||||
.from(MockIntegration.mockMessageSource("foo", "bar", "baz"))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(out)
|
||||
@@ -205,7 +204,7 @@ public class MockMessageSourceTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow myFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(() -> new GenericMessage<>("myData"),
|
||||
e -> e.id("mySourceEndpoint"))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
|
||||
@@ -49,7 +49,6 @@ import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
@@ -267,7 +266,7 @@ public class WebFluxDslTests {
|
||||
@Test
|
||||
public void testDynamicHttpEndpoint() {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(WebFlux.inboundGateway("/dynamic")
|
||||
IntegrationFlow.from(WebFlux.inboundGateway("/dynamic")
|
||||
.requestMapping(r -> r.params("name"))
|
||||
.payloadExpression("#requestParams.name[0]"))
|
||||
.<String, String>transform(String::toLowerCase)
|
||||
@@ -298,7 +297,7 @@ public class WebFluxDslTests {
|
||||
@Disabled("Fails after some recent SF change")
|
||||
public void testValidation() {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
WebFlux.inboundGateway("/validation")
|
||||
.requestMapping((mapping) -> mapping
|
||||
.methods(HttpMethod.POST)
|
||||
@@ -325,7 +324,7 @@ public class WebFluxDslTests {
|
||||
@Test
|
||||
public void testErrorChannelFlow() {
|
||||
IntegrationFlow flow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
WebFlux.inboundGateway("/errorFlow")
|
||||
.errorChannel(new FixedSubscriberChannel(
|
||||
new AbstractReplyProducingMessageHandler() {
|
||||
@@ -421,7 +420,7 @@ public class WebFluxDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow httpReactiveProxyFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Http.inboundGateway("/service2")
|
||||
.requestMapping(r -> r.params("name")))
|
||||
.handle(WebFlux.<MultiValueMap<String, String>>outboundGateway(m ->
|
||||
@@ -436,7 +435,7 @@ public class WebFluxDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow httpReactiveInboundChannelAdapterFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(WebFlux.inboundChannelAdapter("/reactivePost")
|
||||
.requestMapping(m -> m.methods(HttpMethod.POST))
|
||||
.requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class))
|
||||
@@ -450,7 +449,7 @@ public class WebFluxDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow httpReactiveInboundGatewayFlowWithErrors() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(WebFlux.inboundGateway("/reactivePostErrors")
|
||||
.requestMapping(m -> m.methods(HttpMethod.POST))
|
||||
.requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class))
|
||||
@@ -474,7 +473,7 @@ public class WebFluxDslTests {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sseFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(WebFlux.inboundGateway("/sse")
|
||||
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE))
|
||||
.mappedResponseHeaders("*"))
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.websocket.ClientWebSocketContainer;
|
||||
import org.springframework.integration.websocket.ServerWebSocketContainer;
|
||||
@@ -78,7 +77,7 @@ public class WebSocketDslTests {
|
||||
QueueChannel dynamicRequestsChannel = new QueueChannel();
|
||||
|
||||
IntegrationFlow serverFlow =
|
||||
IntegrationFlows.from(webSocketInboundChannelAdapter)
|
||||
IntegrationFlow.from(webSocketInboundChannelAdapter)
|
||||
.channel(dynamicRequestsChannel)
|
||||
.get();
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlows;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.zeromq.ZeroMqHeaders;
|
||||
@@ -78,7 +77,7 @@ public class ZeroMqDslTests {
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
IntegrationFlow consumerFlow =
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
ZeroMq.inboundChannelAdapter(this.context, SocketType.SUB)
|
||||
.connectUrl("tcp://localhost:" + this.subPubZeroMqProxy.getBackendPort())
|
||||
.topics("someTopic")
|
||||
|
||||
@@ -52,7 +52,7 @@ The following listing shows the possible configuration options for an AMQP Inbou
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow amqpInbound(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "aName"))
|
||||
return IntegrationFlow.from(Amqp.inboundAdapter(connectionFactory, "aName"))
|
||||
.handle(m -> System.out.println(m.getPayload()))
|
||||
.get();
|
||||
}
|
||||
@@ -283,7 +283,7 @@ The following example shows how to configure an `AmqpMessageSource`:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE),
|
||||
return IntegrationFlow.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE),
|
||||
e -> e.poller(Pollers.fixedDelay(1_000)).autoStartup(false))
|
||||
.handle(p -> {
|
||||
...
|
||||
@@ -328,7 +328,7 @@ The following listing shows the available attributes:
|
||||
----
|
||||
@Bean // return the upper cased payload
|
||||
public IntegrationFlow amqpInboundGateway(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(Amqp.inboundGateway(connectionFactory, "foo"))
|
||||
return IntegrationFlow.from(Amqp.inboundGateway(connectionFactory, "foo"))
|
||||
.transform(String.class, String::toUpperCase)
|
||||
.get();
|
||||
}
|
||||
@@ -490,7 +490,7 @@ The following example shows the available properties for an AMQP outbound channe
|
||||
@Bean
|
||||
public IntegrationFlow amqpOutbound(AmqpTemplate amqpTemplate,
|
||||
MessageChannel amqpOutboundChannel) {
|
||||
return IntegrationFlows.from(amqpOutboundChannel)
|
||||
return IntegrationFlow.from(amqpOutboundChannel)
|
||||
.handle(Amqp.outboundAdapter(amqpTemplate)
|
||||
.routingKey("queue1")) // default exchange - route to queue 'queue1'
|
||||
.get();
|
||||
@@ -1214,7 +1214,7 @@ The following example shows how to configure the channels with the Java DSL:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow pollableInFlow(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.channel(Amqp.pollableChannel(connectionFactory)
|
||||
.queueName("foo"))
|
||||
@@ -1224,7 +1224,7 @@ public IntegrationFlow pollableInFlow(ConnectionFactory connectionFactory) {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow messageDrivenInFow(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.channel(Amqp.channel(connectionFactory)
|
||||
.queueName("bar"))
|
||||
@@ -1234,7 +1234,7 @@ public IntegrationFlow messageDrivenInFow(ConnectionFactory connectionFactory) {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pubSubInFlow(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.channel(Amqp.publishSubscribeChannel(connectionFactory)
|
||||
.queueName("baz"))
|
||||
@@ -1361,7 +1361,7 @@ Consider the following integration flow:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow(RabbitTemplate template) {
|
||||
return IntegrationFlows.from(Gateway.class)
|
||||
return IntegrationFlow.from(Gateway.class)
|
||||
.split(s -> s.delimiters(","))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.handle(Amqp.outboundAdapter(template).routingKey("rk"))
|
||||
@@ -1385,7 +1385,7 @@ The following example shows how to use `BoundRabbitChannelAdvice`:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow(RabbitTemplate template) {
|
||||
return IntegrationFlows.from(Gateway.class)
|
||||
return IntegrationFlow.from(Gateway.class)
|
||||
.split(s -> s.delimiters(",")
|
||||
.advice(new BoundRabbitChannelAdvice(template, Duration.ofSeconds(10))))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
|
||||
@@ -119,7 +119,7 @@ You can use the Java Domain Specific Language (DSL) to configure a bridge, as th
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow bridgeFlow() {
|
||||
return IntegrationFlows.from("polled")
|
||||
return IntegrationFlow.from("polled")
|
||||
.bridge(e -> e.poller(Pollers.fixedDelay(5000).maxMessagesPerPoll(10)))
|
||||
.channel("direct")
|
||||
.get();
|
||||
|
||||
@@ -23,7 +23,7 @@ The following example defines two `inbound-channel-adapter` instances:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow source1() {
|
||||
return IntegrationFlows.from(() -> new GenericMessage<>(...),
|
||||
return IntegrationFlow.from(() -> new GenericMessage<>(...),
|
||||
e -> e.poller(p -> p.fixedRate(5000)))
|
||||
...
|
||||
.get();
|
||||
@@ -31,7 +31,7 @@ public IntegrationFlow source1() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow source2() {
|
||||
return IntegrationFlows.from(() -> new GenericMessage<>(...),
|
||||
return IntegrationFlow.from(() -> new GenericMessage<>(...),
|
||||
e -> e.poller(p -> p.cron("30 * 9-17 * * MON-FRI")))
|
||||
...
|
||||
.get();
|
||||
|
||||
@@ -687,7 +687,7 @@ public PollableChannel priorityQueue(BasicMessageGroupStore mongoDbChannelMessag
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow priorityFlow(PriorityCapableChannelMessageStore mongoDbChannelMessageStore) {
|
||||
return IntegrationFlows.from((Channels c) ->
|
||||
return IntegrationFlow.from((Channels c) ->
|
||||
c.priority("priorityChannel", mongoDbChannelMessageStore, "priorityGroup"))
|
||||
....
|
||||
.get();
|
||||
|
||||
@@ -58,7 +58,7 @@ Similarly, you can configure Java DSL flow definitions as follows:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow controlBusFlow() {
|
||||
return IntegrationFlows.from("controlBus")
|
||||
return IntegrationFlow.from("controlBus")
|
||||
.controlBus()
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ If you need to determine the delay for each message, you can also provide the Sp
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.delay("delayer.messageGroupId", d -> d
|
||||
.defaultDelay(3_000L)
|
||||
.delayExpression("headers['delay']"))
|
||||
|
||||
@@ -11,7 +11,7 @@ We also use and support lambdas (available with Java 8) to further simplify Java
|
||||
|
||||
The https://github.com/spring-projects/spring-integration-samples/tree/main/dsl/cafe-dsl[cafe] offers a good example of using the DSL.
|
||||
|
||||
The DSL is presented by the `IntegrationFlows` factory for the `IntegrationFlowBuilder`.
|
||||
The DSL is presented by the `IntegrationFlow` fluent API (see `IntegrationFlowBuilder`).
|
||||
This produces the `IntegrationFlow` component, which should be registered as a Spring bean (by using the `@Bean` annotation).
|
||||
The builder pattern is used to express arbitrarily complex structures as a hierarchy of methods that can accept lambdas as arguments.
|
||||
|
||||
@@ -38,7 +38,7 @@ public class MyConfiguration {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow myFlow() {
|
||||
return IntegrationFlows.fromSupplier(integerSource()::getAndIncrement,
|
||||
return IntegrationFlow.fromSupplier(integerSource()::getAndIncrement,
|
||||
c -> c.poller(Pollers.fixedRate(100)))
|
||||
.channel("inputChannel")
|
||||
.filter((Integer p) -> p > 0)
|
||||
@@ -76,14 +76,14 @@ Conceptually, integration processes are constructed by composing these endpoints
|
||||
Note that EIP does not formally define the term 'message flow', but it is useful to think of it as a unit of work that uses well known messaging patterns.
|
||||
The DSL provides an `IntegrationFlow` component to define a composition of channels and endpoints between them, but now `IntegrationFlow` plays only the configuration role to populate real beans in the application context and is not used at runtime.
|
||||
However, the bean for `IntegrationFlow` can be autowired as a `Lifecycle` to control `start()` and `stop()` for the whole flow which is delegated to all the Spring Integration components associated with this `IntegrationFlow`.
|
||||
The following example uses the `IntegrationFlows` factory to define an `IntegrationFlow` bean by using EIP-methods from `IntegrationFlowBuilder`:
|
||||
The following example uses the `IntegrationFlow` fluent API to define an `IntegrationFlow` bean by using EIP-methods from `IntegrationFlowBuilder`:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow integerFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.<String, Integer>transform(Integer::parseInt)
|
||||
.get();
|
||||
}
|
||||
@@ -102,7 +102,7 @@ Consider another example:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow myFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.filter("World"::equals)
|
||||
.transform("Hello "::concat)
|
||||
.handle(System.out::println)
|
||||
@@ -190,7 +190,7 @@ public MessageChannel publishSubscribe() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow channelFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.fixedSubscriberChannel()
|
||||
.channel("queueChannel")
|
||||
.channel(publishSubscribe())
|
||||
@@ -217,7 +217,7 @@ The following example is wrong:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow startFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.transform(...)
|
||||
.channel(MessageChannels.queue("queueChannel"))
|
||||
.get();
|
||||
@@ -225,7 +225,7 @@ public IntegrationFlow startFlow() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow endFlow() {
|
||||
return IntegrationFlows.from(MessageChannels.queue("queueChannel"))
|
||||
return IntegrationFlow.from(MessageChannels.queue("queueChannel"))
|
||||
.handle(...)
|
||||
.get();
|
||||
}
|
||||
@@ -276,7 +276,7 @@ The following example demonstrates how to change the publishing thread from the
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow reactiveEndpointFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from("inputChannel")
|
||||
.<String, Integer>transform(Integer::parseInt,
|
||||
e -> e.reactive(flux -> flux.publishOn(Schedulers.parallel())))
|
||||
@@ -298,7 +298,7 @@ Each of them has generic arguments, so it lets you configure an endpoint and eve
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow2() {
|
||||
return IntegrationFlows.from(this.inputChannel)
|
||||
return IntegrationFlow.from(this.inputChannel)
|
||||
.transform(new PayloadSerializingTransformer(),
|
||||
c -> c.autoStartup(false).id("payloadSerializingTransformer"))
|
||||
.transform((Integer p) -> p * 2, c -> c.advice(this.expressionAdvice()))
|
||||
@@ -342,7 +342,7 @@ The following example shows how to use it:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow transformFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.transform(Transformers.fromJson(MyPojo.class))
|
||||
.transform(Transformers.serializer())
|
||||
.get();
|
||||
@@ -364,9 +364,9 @@ Also see <<java-dsl-class-cast>>.
|
||||
Typically, message flows start from an inbound channel adapter (such as `<int-jdbc:inbound-channel-adapter>`).
|
||||
The adapter is configured with `<poller>`, and it asks a `MessageSource<?>` to periodically produce messages.
|
||||
Java DSL allows for starting `IntegrationFlow` from a `MessageSource<?>`, too.
|
||||
For this purpose, the `IntegrationFlows` builder factory provides an overloaded `IntegrationFlows.from(MessageSource<?> messageSource)` method.
|
||||
For this purpose, the `IntegrationFlow` fluent API provides an overloaded `IntegrationFlow.from(MessageSource<?> messageSource)` method.
|
||||
You can configure the `MessageSource<?>` as a bean and provide it as an argument for that method.
|
||||
The second parameter of `IntegrationFlows.from()` is a `Consumer<SourcePollingChannelAdapterSpec>` lambda that lets you provide options (such as `PollerMetadata` or `SmartLifecycle`) for the `SourcePollingChannelAdapter`.
|
||||
The second parameter of `IntegrationFlow.from()` is a `Consumer<SourcePollingChannelAdapterSpec>` lambda that lets you provide options (such as `PollerMetadata` or `SmartLifecycle`) for the `SourcePollingChannelAdapter`.
|
||||
The following example shows how to use the fluent API and a lambda to create an `IntegrationFlow`:
|
||||
|
||||
====
|
||||
@@ -379,7 +379,7 @@ public MessageSource<Object> jdbcMessageSource() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pollingFlow() {
|
||||
return IntegrationFlows.from(jdbcMessageSource(),
|
||||
return IntegrationFlow.from(jdbcMessageSource(),
|
||||
c -> c.poller(Pollers.fixedRate(100).maxMessagesPerPoll(1)))
|
||||
.transform(Transformers.toJson())
|
||||
.channel("furtherProcessChannel")
|
||||
@@ -388,7 +388,7 @@ public IntegrationFlow pollingFlow() {
|
||||
----
|
||||
====
|
||||
|
||||
For those cases that have no requirements to build `Message` objects directly, you can use a `IntegrationFlows.fromSupplier()` variant that is based on the `java.util.function.Supplier` .
|
||||
For those cases that have no requirements to build `Message` objects directly, you can use a `IntegrationFlow.fromSupplier()` variant that is based on the `java.util.function.Supplier` .
|
||||
The result of the `Supplier.get()` is automatically wrapped in a `Message` (if it is not already a `Message`).
|
||||
|
||||
[[java-dsl-routers]]
|
||||
@@ -411,7 +411,7 @@ The fluent API also provides `AbstractMappingMessageRouter` options such as `cha
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routeFlowByLambda() {
|
||||
return IntegrationFlows.from("routerInput")
|
||||
return IntegrationFlow.from("routerInput")
|
||||
.<Integer, Boolean>route(p -> p % 2 == 0,
|
||||
m -> m.suffix("Channel")
|
||||
.channelMapping(true, "even")
|
||||
@@ -429,7 +429,7 @@ The following example shows a simple expression-based router:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routeFlowByExpression() {
|
||||
return IntegrationFlows.from("routerInput")
|
||||
return IntegrationFlow.from("routerInput")
|
||||
.route("headers['destChannel']")
|
||||
.get();
|
||||
}
|
||||
@@ -443,7 +443,7 @@ The `routeToRecipients()` method takes a `Consumer<RecipientListRouterSpec>`, as
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow recipientListFlow() {
|
||||
return IntegrationFlows.from("recipientListInput")
|
||||
return IntegrationFlow.from("recipientListInput")
|
||||
.<String, String>transform(p -> p.replaceFirst("Payload", ""))
|
||||
.routeToRecipients(r -> r
|
||||
.recipient("thing1-channel", "'thing1' == payload")
|
||||
@@ -482,7 +482,7 @@ The following example shows how to use the `split()` method by providing a lambd
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow splitFlow() {
|
||||
return IntegrationFlows.from("splitInput")
|
||||
return IntegrationFlow.from("splitInput")
|
||||
.split(s -> s.applySequence(false).delimiters(","))
|
||||
.channel(MessageChannels.executor(taskExecutor()))
|
||||
.get();
|
||||
@@ -506,7 +506,7 @@ The following example shows a canonical example of the splitter-aggregator patte
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow splitAggregateFlow() {
|
||||
return IntegrationFlows.from("splitAggregateInput")
|
||||
return IntegrationFlow.from("splitAggregateInput")
|
||||
.split()
|
||||
.channel(MessageChannels.executor(this.taskExecutor()))
|
||||
.resequence()
|
||||
@@ -550,7 +550,7 @@ Having that, we can define a flow as follows:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow myFlow() {
|
||||
return IntegrationFlows.from("flow3Input")
|
||||
return IntegrationFlow.from("flow3Input")
|
||||
.<Integer>handle((p, h) -> p * 2)
|
||||
.get();
|
||||
}
|
||||
@@ -569,7 +569,7 @@ The following example shows what the resulting `IntegrationFlow` might look like
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow integerFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.<byte[], String>transform(p - > new String(p, "UTF-8"))
|
||||
.handle(Integer.class, (p, h) -> p * 2)
|
||||
.get();
|
||||
@@ -590,7 +590,7 @@ public BytesToIntegerConverter bytesToIntegerConverter() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow integerFlow() {
|
||||
return IntegrationFlows.from("input")
|
||||
return IntegrationFlow.from("input")
|
||||
.handle(Integer.class, (p, h) -> p * 2)
|
||||
.get();
|
||||
}
|
||||
@@ -619,7 +619,7 @@ Also, the `IntegrationFlow`-based methods allows calling existing `IntegrationFl
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow someFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(...)
|
||||
.gateway(subFlow())
|
||||
.handle(...)
|
||||
@@ -971,7 +971,7 @@ The following example shows how to use three of them (`Amqp`, `Jms`, and `Mail`)
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow amqpFlow() {
|
||||
return IntegrationFlows.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue()))
|
||||
return IntegrationFlow.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue()))
|
||||
.transform("hello "::concat)
|
||||
.transform(String.class, String::toUpperCase)
|
||||
.get();
|
||||
@@ -979,7 +979,7 @@ public IntegrationFlow amqpFlow() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsOutboundGatewayFlow() {
|
||||
return IntegrationFlows.from("jmsOutboundGatewayChannel")
|
||||
return IntegrationFlow.from("jmsOutboundGatewayChannel")
|
||||
.handle(Jms.outboundGateway(this.jmsConnectionFactory)
|
||||
.replyContainer(c ->
|
||||
c.concurrentConsumers(3)
|
||||
@@ -990,7 +990,7 @@ public IntegrationFlow jmsOutboundGatewayFlow() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sendMailFlow() {
|
||||
return IntegrationFlows.from("sendMailChannel")
|
||||
return IntegrationFlow.from("sendMailChannel")
|
||||
.handle(Mail.outboundAdapter("localhost")
|
||||
.port(smtpPort)
|
||||
.credentials("user", "pw")
|
||||
@@ -1024,7 +1024,7 @@ public QueueChannelSpec wrongMessagesChannel() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow xpathFlow(MessageChannel wrongMessagesChannel) {
|
||||
return IntegrationFlows.from("inputChannel")
|
||||
return IntegrationFlow.from("inputChannel")
|
||||
.filter(new StringValueTestXPathMessageSelector("namespace-uri(/*)", "my:namespace"),
|
||||
e -> e.discardChannel(wrongMessagesChannel))
|
||||
.log(LoggingHandler.Level.ERROR, "test.category", m -> m.getHeaders().getId())
|
||||
@@ -1200,7 +1200,7 @@ Flux<Message<?>> messageFlux =
|
||||
QueueChannel resultChannel = new QueueChannel();
|
||||
|
||||
IntegrationFlow integrationFlow =
|
||||
IntegrationFlows.from(messageFlux)
|
||||
IntegrationFlow.from(messageFlux)
|
||||
.<Integer, Integer>transform(p -> p * 2)
|
||||
.channel(resultChannel)
|
||||
.get();
|
||||
@@ -1274,7 +1274,7 @@ public interface ControlBusGateway {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow controlBusFlow() {
|
||||
return IntegrationFlows.from(ControlBusGateway.class)
|
||||
return IntegrationFlow.from(ControlBusGateway.class)
|
||||
.controlBus()
|
||||
.get();
|
||||
}
|
||||
@@ -1287,7 +1287,7 @@ Nevertheless, the `requestChannel` is ignored and overridden with that internal
|
||||
Otherwise, creating such a configuration by using `IntegrationFlow` does not make sense.
|
||||
|
||||
By default, a `GatewayProxyFactoryBean` gets a conventional bean name, such as `[FLOW_BEAN_NAME.gateway]`.
|
||||
You can change that ID by using the `@MessagingGateway.name()` attribute or the overloaded `IntegrationFlows.from(Class<?> serviceInterface, Consumer<GatewayProxySpec> endpointConfigurer)` factory method.
|
||||
You can change that ID by using the `@MessagingGateway.name()` attribute or the overloaded `IntegrationFlow.from(Class<?> serviceInterface, Consumer<GatewayProxySpec> endpointConfigurer)` factory method.
|
||||
Also, all the attributes from the `@MessagingGateway` annotation on the interface are applied to the target `GatewayProxyFactoryBean`.
|
||||
When annotation configuration is not applicable, the `Consumer<GatewayProxySpec>` variant can be used for providing appropriate option for the target proxy.
|
||||
This DSL method is available starting with version 5.2.
|
||||
@@ -1299,7 +1299,7 @@ With Java 8, you can even create an integration gateway with the `java.util.func
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow errorRecovererFlow() {
|
||||
return IntegrationFlows.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
|
||||
return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction"))
|
||||
.handle((GenericHandler<?>) (p, h) -> {
|
||||
throw new RuntimeException("intentional");
|
||||
}, e -> e.advice(retryAdvice()))
|
||||
@@ -1387,21 +1387,21 @@ The input channel of any endpoint in the flow can be used to send messages from
|
||||
Furthermore, with a `@MessagingGateway` contract, Content Enricher components, composite endpoints like a `<chain>`, and now with `IntegrationFlow` beans (e.g. `IntegrationFlowAdapter`), it is straightforward enough to distribute the business logic between shorter, reusable parts.
|
||||
All that is needed for the final composition is knowledge about a `MessageChannel` to send to or receive from.
|
||||
|
||||
Starting with version `5.5.4`, to abstract more from `MessageChannel` and hide implementation details from the end-user, the `IntegrationFlows` introduces the `from(IntegrationFlow)` factory method to allow starting the current `IntegrationFlow` from the output of an existing flow:
|
||||
Starting with version `5.5.4`, to abstract more from `MessageChannel` and hide implementation details from the end-user, the `IntegrationFlow` introduces the `from(IntegrationFlow)` factory method to allow starting the current `IntegrationFlow` from the output of an existing flow:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow templateSourceFlow() {
|
||||
return IntegrationFlows.fromSupplier(() -> "test data")
|
||||
return IntegrationFlow.fromSupplier(() -> "test data")
|
||||
.channel("sourceChannel")
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
IntegrationFlow compositionMainFlow(IntegrationFlow templateSourceFlow) {
|
||||
return IntegrationFlows.from(templateSourceFlow)
|
||||
return IntegrationFlow.from(templateSourceFlow)
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(c -> c.queue("compositionMainFlowResult"))
|
||||
.get();
|
||||
|
||||
@@ -339,7 +339,7 @@ public PollerMetadata defaultPoller() {
|
||||
// No 'poller' attribute because there is a default global poller
|
||||
@Bean
|
||||
public IntegrationFlow transformFlow(MyTransformer transformer) {
|
||||
return IntegrationFlows.from(MessageChannels.queue("pollable"))
|
||||
return IntegrationFlow.from(MessageChannels.queue("pollable"))
|
||||
.transform(transformer) // No 'poller' attribute because there is a default global poller
|
||||
.channel("output")
|
||||
.get();
|
||||
|
||||
@@ -91,7 +91,7 @@ public ApplicationEventListeningMessageProducer eventsAdapter() {
|
||||
public IntegrationFlow eventFlow(ApplicationEventListeningMessageProducer eventsAdapter,
|
||||
MessageChannel eventErrorChannel) {
|
||||
|
||||
return IntegrationFlows.from(eventsAdapter, e -> e.errorChannel(eventErrorChannel))
|
||||
return IntegrationFlow.from(eventsAdapter, e -> e.errorChannel(eventErrorChannel))
|
||||
.handle(...)
|
||||
...
|
||||
.get();
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ContextConfiguration {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow feedFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Feed.inboundAdapter(this.feedResource, "feedTest")
|
||||
.preserveWireFeed(true),
|
||||
e -> e.poller(p -> p.fixedDelay(100)))
|
||||
|
||||
@@ -462,7 +462,7 @@ public class FileReadingJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileReadingFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Files.inboundAdapter(new File(INBOUND_PATH))
|
||||
.patternFilter("*.txt"),
|
||||
e -> e.poller(Pollers.fixedDelay(1000)))
|
||||
@@ -929,7 +929,7 @@ public class FileWritingJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileWritingFlow() {
|
||||
return IntegrationFlows.from("fileWritingInput")
|
||||
return IntegrationFlow.from("fileWritingInput")
|
||||
.enrichHeaders(h -> h.header(FileHeaders.FILENAME, "foo.txt")
|
||||
.header("directory", new File(tmpDir.getRoot(), "fileWritingFlow")))
|
||||
.handle(Files.outboundGateway(m -> m.getHeaders().get("directory")))
|
||||
@@ -1006,7 +1006,7 @@ public class FileSplitterApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow fileSplitterFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Files.inboundAdapter(tmpDir.getRoot())
|
||||
.filter(new ChainFileListFilter<File>()
|
||||
.addFilter(new AcceptOnceFileListFilter<>())
|
||||
|
||||
@@ -559,7 +559,7 @@ public class FtpJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow ftpInboundFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Ftp.inboundAdapter(this.ftpSessionFactory)
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("foo")
|
||||
@@ -772,7 +772,7 @@ This allows files retrieved from different directories to be downloaded to simil
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Ftp.inboundAdapter(sf())
|
||||
return IntegrationFlow.from(Ftp.inboundAdapter(sf())
|
||||
.filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.localDirectory(new File(tmpDir))
|
||||
.localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root")
|
||||
@@ -979,7 +979,7 @@ public class FtpJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow ftpOutboundFlow() {
|
||||
return IntegrationFlows.from("toFtpChannel")
|
||||
return IntegrationFlow.from("toFtpChannel")
|
||||
.handle(Ftp.outboundAdapter(ftpSessionFactory(), FileExistsMode.FAIL)
|
||||
.useTemporaryFileName(false)
|
||||
.fileNameExpression("headers['" + FileHeaders.FILENAME + "']")
|
||||
|
||||
@@ -101,7 +101,7 @@ public Supplier<String> stringSupplier() {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow supplierFlow() {
|
||||
return IntegrationFlows.from(stringSupplier())
|
||||
return IntegrationFlow.from(stringSupplier())
|
||||
.transform(toUpperCaseFunction())
|
||||
.channel("suppliedChannel")
|
||||
.get();
|
||||
|
||||
@@ -893,4 +893,4 @@ At that time, the calling thread starts waiting for the reply.
|
||||
If the flow was completely synchronous, the reply is immediately available.
|
||||
For asynchronous flows, the thread waits for up to this time.
|
||||
|
||||
See <<./dsl.adoc#integration-flow-as-gateway,`IntegrationFlow` as Gateway>> in the Java DSL chapter for options to define gateways through `IntegrationFlows`.
|
||||
See <<./dsl.adoc#integration-flow-as-gateway,`IntegrationFlow` as Gateway>> in the Java DSL chapter for options to define gateways through `IntegrationFlow`.
|
||||
|
||||
@@ -61,7 +61,7 @@ GraphQlMessageHandler handler(ExecutionGraphQlService graphQlService) {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow graphqlQueryMessageHandlerFlow(GraphQlMessageHandler handler) {
|
||||
return IntegrationFlows.from(MessageChannels.flux("inputChannel"))
|
||||
return IntegrationFlow.from(MessageChannels.flux("inputChannel"))
|
||||
.handle(handler)
|
||||
.channel(c -> c.flux("resultChannel"))
|
||||
.get();
|
||||
|
||||
@@ -775,7 +775,7 @@ The following example shows how to configure an inbound gateway with the Java DS
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow inbound() {
|
||||
return IntegrationFlows.from(Http.inboundGateway("/foo")
|
||||
return IntegrationFlow.from(Http.inboundGateway("/foo")
|
||||
.requestMapping(m -> m.methods(HttpMethod.POST))
|
||||
.requestPayloadType(String.class))
|
||||
.channel("httpRequest")
|
||||
@@ -810,7 +810,7 @@ The following example shows how to configure an outbound gateway with the Java D
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow outbound() {
|
||||
return IntegrationFlows.from("httpOutRequest")
|
||||
return IntegrationFlow.from("httpOutRequest")
|
||||
.handle(Http.outboundGateway("http://localhost:8080/foo")
|
||||
.httpMethod(HttpMethod.POST)
|
||||
.expectedResponseType(String.class))
|
||||
|
||||
@@ -228,7 +228,7 @@ The following example shows how to configure an inbound UDP adapter with the Jav
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow udpIn() {
|
||||
return IntegrationFlows.from(Udp.inboundAdapter(11111))
|
||||
return IntegrationFlow.from(Udp.inboundAdapter(11111))
|
||||
.channel("udpChannel")
|
||||
.get();
|
||||
}
|
||||
@@ -283,7 +283,7 @@ The following example shows the equivalent configuration with the Java DSL:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow udpEchoUpcaseServer() {
|
||||
return IntegrationFlows.from(Udp.inboundAdapter(11111).id("udpIn"))
|
||||
return IntegrationFlow.from(Udp.inboundAdapter(11111).id("udpIn"))
|
||||
.<byte[], String>transform(p -> new String(p).toUpperCase())
|
||||
.handle(Udp.outboundAdapter("headers['ip_packetAddress']")
|
||||
.socketExpression("@udpIn.socket"))
|
||||
@@ -2266,7 +2266,7 @@ Here are some examples of using the DSL to configure flows using the DSL.
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow server() {
|
||||
return IntegrationFlows.from(Tcp.inboundAdapter(Tcp.netServer(1234)
|
||||
return IntegrationFlow.from(Tcp.inboundAdapter(Tcp.netServer(1234)
|
||||
.deserializer(TcpCodecs.lengthHeader1())
|
||||
.backlog(30))
|
||||
.errorChannel("tcpIn.errorChannel")
|
||||
@@ -2296,7 +2296,7 @@ public IntegrationFlow client() {
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow server() {
|
||||
return IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(1234)
|
||||
return IntegrationFlow.from(Tcp.inboundGateway(Tcp.netServer(1234)
|
||||
.deserializer(TcpCodecs.lengthHeader1())
|
||||
.serializer(TcpCodecs.lengthHeader1())
|
||||
.backlog(30))
|
||||
|
||||
@@ -56,7 +56,7 @@ The following example defines an inbound channel adapter with a `Destination` re
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow jmsInbound(ConnectionFactory connectionFactory) {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
Jms.inboundAdapter(connectionFactory)
|
||||
.destination("inQueue"),
|
||||
e -> e.poller(poller -> poller.fixedRate(30000)))
|
||||
@@ -148,7 +148,7 @@ The following example defines a message-driven channel adapter with a `Destinati
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow jmsMessageDrivenRedeliveryFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jms.messageDrivenChannelAdapter(jmsConnectionFactory())
|
||||
.destination("inQueue"))
|
||||
.channel("exampleChannel")
|
||||
|
||||
@@ -445,7 +445,7 @@ public class JpaJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pollingAdapterFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Jpa.inboundAdapter(this.entityManagerFactory)
|
||||
.entityClass(StudentDomain.class)
|
||||
.maxResults(1)
|
||||
|
||||
@@ -239,7 +239,7 @@ The following example shows how to configure a message-driven channel adapter:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow topic1ListenerFromKafkaFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.messageDrivenChannelAdapter(consumerFactory(),
|
||||
KafkaMessageDrivenChannelAdapter.ListenerMode.record, TEST_TOPIC1)
|
||||
.configureListenerContainer(c ->
|
||||
@@ -332,7 +332,7 @@ The following example shows how to do so:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow topic2ListenerFromKafkaFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.messageDrivenChannelAdapter(kafkaListenerContainerFactory().createContainer(TEST_TOPIC2),
|
||||
KafkaMessageDrivenChannelAdapter.ListenerMode.record)
|
||||
.id("topic2Adapter"))
|
||||
@@ -360,7 +360,7 @@ The `KafkaMessageSource` provides a pollable channel adapter implementation.
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow(ConsumerFactory<String, String> cf) {
|
||||
return IntegrationFlows.from(Kafka.inboundChannelAdapter(cf, "myTopic")
|
||||
return IntegrationFlow.from(Kafka.inboundChannelAdapter(cf, "myTopic")
|
||||
.groupId("myDslGroupId"), e -> e.poller(Pollers.fixedDelay(5000)))
|
||||
.handle(System.out::println)
|
||||
.get();
|
||||
@@ -437,7 +437,7 @@ The following example shows how to configure a gateway:
|
||||
public IntegrationFlow outboundGateFlow(
|
||||
ReplyingKafkaTemplate<String, String, String> kafkaTemplate) {
|
||||
|
||||
return IntegrationFlows.from("kafkaRequests")
|
||||
return IntegrationFlow.from("kafkaRequests")
|
||||
.handle(Kafka.outboundGateway(kafkaTemplate))
|
||||
.channel("kafkaReplies")
|
||||
.get();
|
||||
@@ -497,7 +497,7 @@ Alternatively, you can also use a configuration similar to the following bean:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow outboundGateFlow() {
|
||||
return IntegrationFlows.from("kafkaRequests")
|
||||
return IntegrationFlow.from("kafkaRequests")
|
||||
.handle(Kafka.outboundGateway(producerFactory(), replyContainer())
|
||||
.configureKafkaTemplate(t -> t.replyTimeout(30_000)))
|
||||
.channel("kafkaReplies")
|
||||
@@ -524,7 +524,7 @@ The following example shows how to configure an inbound gateway:
|
||||
public IntegrationFlow serverGateway(
|
||||
ConcurrentMessageListenerContainer<Integer, String> container,
|
||||
KafkaTemplate<Integer, String> replyTemplate) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.inboundGateway(container, replyTemplate)
|
||||
.replyTimeout(30_000))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
@@ -589,7 +589,7 @@ Alternatively, you could configure an upper-case converter by using code similar
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow serverGateway() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Kafka.inboundGateway(consumerFactory(), containerProperties(),
|
||||
producerFactory())
|
||||
.replyTimeout(30_000))
|
||||
@@ -619,7 +619,7 @@ Each channel requires a `KafkaTemplate` for the sending side and either a listen
|
||||
public IntegrationFlow flowWithSubscribable(KafkaTemplate<Integer, String> template,
|
||||
ConcurrentKafkaListenerContainerFactory<Integer, String> containerFactory) {
|
||||
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.channel(Kafka.channel(template, containerFactory, "someTopic1").groupId("group1"))
|
||||
...
|
||||
@@ -630,7 +630,7 @@ public IntegrationFlow flowWithSubscribable(KafkaTemplate<Integer, String> templ
|
||||
public IntegrationFlow flowWithPubSub(KafkaTemplate<Integer, String> template,
|
||||
ConcurrentKafkaListenerContainerFactory<Integer, String> containerFactory) {
|
||||
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.publishSubscribeChannel(pubSub(template, containerFactory),
|
||||
pubsub -> pubsub
|
||||
@@ -652,7 +652,7 @@ public BroadcastCapableChannel pubSub(KafkaTemplate<Integer, String> template,
|
||||
public IntegrationFlow flowWithPollable(KafkaTemplate<Integer, String> template,
|
||||
KafkaMessageSource<Integer, String> source) {
|
||||
|
||||
return IntegrationFlows.from(...)
|
||||
return IntegrationFlow.from(...)
|
||||
...
|
||||
.channel(Kafka.pollableChannel(template, source, "someTopic3").groupId("group3"))
|
||||
.handle(..., e -> e.poller(...))
|
||||
@@ -821,7 +821,7 @@ public MessagingTransformer<byte[], byte[], String> transformer(
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(MessagingFunction.class)
|
||||
return IntegrationFlow.from(MessagingFunction.class)
|
||||
...
|
||||
.get();
|
||||
}
|
||||
@@ -856,7 +856,7 @@ public class FuturesChannelApplication {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow inbound(ConsumerFactory<String, String> consumerFactory, Handler handler) {
|
||||
return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(consumerFactory,
|
||||
return IntegrationFlow.from(Kafka.messageDrivenChannelAdapter(consumerFactory,
|
||||
ListenerMode.batch, "inTopic"))
|
||||
.handle(handler)
|
||||
.get();
|
||||
@@ -864,7 +864,7 @@ public class FuturesChannelApplication {
|
||||
|
||||
@Bean
|
||||
IntegrationFlow outbound(KafkaTemplate<String, String> kafkaTemplate) {
|
||||
return IntegrationFlows.from(Gate.class)
|
||||
return IntegrationFlow.from(Gate.class)
|
||||
.enrichHeaders(h -> h
|
||||
.header(KafkaHeaders.TOPIC, "outTopic")
|
||||
.headerExpression(KafkaIntegrationHeaders.FUTURE_TOKEN, "headers[id]"))
|
||||
|
||||
@@ -41,22 +41,22 @@ Such a global `integrationFlow()` function expects a lambda in builder style for
|
||||
See more overloaded `integrationFlow()` variants below.
|
||||
|
||||
Many other scenarios require an `IntegrationFlow` to be started from source of data (e.g. `JdbcPollingChannelAdapter`, `JmsInboundGateway` or just an existing `MessageChannel`).
|
||||
For this purpose, the Spring Integration Java DSL provides an `IntegrationFlows` factory with its large number of overloaded `from()` methods.
|
||||
This factory can be used in Kotlin as well:
|
||||
For this purpose, the Spring Integration Java DSL provides an `IntegrationFlow` fluent API with its large number of overloaded `from()` methods.
|
||||
This API can be used in Kotlin as well:
|
||||
|
||||
====
|
||||
[source, kotlin]
|
||||
----
|
||||
@Bean
|
||||
fun flowFromSupplier() =
|
||||
IntegrationFlows.from<String>({ "bar" }) { e -> e.poller { p -> p.fixedDelay(10).maxMessagesPerPoll(1) } }
|
||||
IntegrationFlow.from<String>({ "bar" }) { e -> e.poller { p -> p.fixedDelay(10).maxMessagesPerPoll(1) } }
|
||||
.channel { c -> c.queue("fromSupplierQueue") }
|
||||
.get()
|
||||
----
|
||||
====
|
||||
|
||||
But unfortunately not all `from()` methods are compatible with Kotlin structures.
|
||||
To fix the gap, this project provides a Kotlin DSL around an `IntegrationFlows` factory.
|
||||
To fix the gap, this project provides a Kotlin DSL around an `IntegrationFlow` fluent API.
|
||||
It is implemented as a set of overloaded `integrationFlow()` functions.
|
||||
With a consumer for a `KotlinIntegrationFlowDefinition` to declare the rest of the flow as an `IntegrationFlow` lambda to reuse the mentioned above experience and also avoid `get()` call in the end.
|
||||
For example:
|
||||
|
||||
@@ -98,7 +98,7 @@ public class LoggingJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow loggingFlow() {
|
||||
return IntegrationFlows.from(MyGateway.class)
|
||||
return IntegrationFlow.from(MyGateway.class)
|
||||
.log(LoggingHandler.Level.DEBUG, "TEST_LOGGER",
|
||||
m -> m.getHeaders().getId() + ": " + m.getPayload());
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ public class MailApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow imapMailFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Mail.imapInboundAdapter("imap://user:pw@host:port/INBOX")
|
||||
.searchTermStrategy(this::fromAndNotSeenTerm)
|
||||
.userFlag("testSIUserFlag")
|
||||
@@ -626,7 +626,7 @@ public class MailApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sendMailFlow() {
|
||||
return IntegrationFlows.from("sendMailChannel")
|
||||
return IntegrationFlow.from("sendMailChannel")
|
||||
.enrichHeaders(Mail.headers()
|
||||
.subjectFunction(m -> "foo")
|
||||
.from("foo@bar")
|
||||
|
||||
@@ -364,7 +364,7 @@ The Java DSL configuration for this channel adapter may look like this:
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow changeStreamFlow(ReactiveMongoOperations mongoTemplate) {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
MongoDb.changeStreamInboundChannelAdapter(mongoTemplate)
|
||||
.domainType(Person.class)
|
||||
.collection("person")
|
||||
@@ -602,7 +602,7 @@ With Java DSL such a channel adapter could be configured like:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow reactiveMongoDbFlow(ReactiveMongoDatabaseFactory mongoDbFactory) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(MongoDb.reactiveInboundChannelAdapter(mongoDbFactory, "{'name' : 'Name'}")
|
||||
.entityClass(Person.class),
|
||||
c -> c.poller(Pollers.fixedDelay(1000)))
|
||||
|
||||
@@ -237,7 +237,7 @@ public class MqttJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow mqttInbound() {
|
||||
return IntegrationFlows.from(
|
||||
return IntegrationFlow.from(
|
||||
new MqttPahoMessageDrivenChannelAdapter("tcp://localhost:1883",
|
||||
"testClient", "topic1", "topic2");)
|
||||
.handle(m -> System.out.println(m.getPayload()))
|
||||
@@ -488,7 +488,7 @@ public IntegrationFlow mqttInFlow() {
|
||||
messageProducer.setMessageConverter(mqttStringToBytesConverter());
|
||||
messageProducer.setManualAcks(true);
|
||||
|
||||
return IntegrationFlows.from(messageProducer)
|
||||
return IntegrationFlow.from(messageProducer)
|
||||
.channel(c -> c.queue("fromMqttChannel"))
|
||||
.get();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ With Java DSL a configuration for this channel adapter is like this:
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow r2dbcDslFlow(R2dbcEntityTemplate r2dbcEntityTemplate) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(R2dbc.inboundChannelAdapter(r2dbcEntityTemplate,
|
||||
(selectCreator) ->
|
||||
selectCreator.createSelect("person")
|
||||
|
||||
@@ -122,7 +122,7 @@ See <<./splitter.adoc#split-stream-and-flux,Stream and Flux Splitting>> and <<./
|
||||
|
||||
=== Java DSL
|
||||
|
||||
An `IntegrationFlow` in Java DSL can start from any `Publisher` instance (see `IntegrationFlows.from(Publisher<Message<T>>)`).
|
||||
An `IntegrationFlow` in Java DSL can start from any `Publisher` instance (see `IntegrationFlow.from(Publisher<Message<T>>)`).
|
||||
Also, with an `IntegrationFlowBuilder.toReactivePublisher()` operator, the `IntegrationFlow` can be turned into a reactive hot source.
|
||||
A `FluxMessageChannel` is used internally in both cases; it can subscribe to an inbound `Publisher` according to its `ReactiveStreamsSubscribableChannel` contract and it is a `Publisher<Message<?>>` by itself for downstream subscribers.
|
||||
With a dynamic `IntegrationFlow` registration we can implement a powerful logic combining Reactive Streams with this integration flow bridging to/from `Publisher`.
|
||||
@@ -205,7 +205,7 @@ public class MainFlow {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow buildFlow() {
|
||||
return IntegrationFlows.from(customReactiveMessageProducer)
|
||||
return IntegrationFlow.from(customReactiveMessageProducer)
|
||||
.channel(outputChannel)
|
||||
.get();
|
||||
}
|
||||
@@ -221,7 +221,7 @@ Or in a declarative way:
|
||||
public class MainFlow {
|
||||
@Bean
|
||||
public IntegrationFlow buildFlow() {
|
||||
return IntegrationFlows.from(new CustomReactiveMessageProducer(new CustomReactiveSource()))
|
||||
return IntegrationFlow.from(new CustomReactiveMessageProducer(new CustomReactiveSource()))
|
||||
.handle(outputChannel)
|
||||
.get();
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class MainFlow {
|
||||
.withPayload(event.getBody())
|
||||
.setHeader(MyReactiveHeaders.SOURCE_NAME, event.getSourceName())
|
||||
.build());
|
||||
return IntegrationFlows.from(myFlux)
|
||||
return IntegrationFlow.from(myFlux)
|
||||
.handle(outputChannel)
|
||||
.get();
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class MainFlow {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow buildFlow() {
|
||||
return IntegrationFlows.from(customReactiveMessageProducer)
|
||||
return IntegrationFlow.from(customReactiveMessageProducer)
|
||||
.transform(someOperation)
|
||||
.handle(customReactiveMessageHandler)
|
||||
.get();
|
||||
|
||||
@@ -464,7 +464,7 @@ First, you can define the router object as shown in the preceding example:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow1() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route(router())
|
||||
.get();
|
||||
}
|
||||
@@ -487,7 +487,7 @@ Second, you can define the routing function within the DSL flow itself, as the f
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow2() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.<Object, Class<?>>route(Object::getClass, m -> m
|
||||
.channelMapping(String.class, "stringChannel")
|
||||
.channelMapping(Integer.class, "integerChannel"))
|
||||
@@ -555,7 +555,7 @@ First, you can define the router object as shown in the preceding example:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow1() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route(router())
|
||||
.get();
|
||||
}
|
||||
@@ -579,7 +579,7 @@ Second, you can define the routing function within the DSL flow itself, as the f
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow2() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route(Message.class, m -> m.getHeaders().get("testHeader", String.class),
|
||||
m -> m
|
||||
.channelMapping("someHeaderValue", "channelA")
|
||||
@@ -673,7 +673,7 @@ The following example shows the equivalent router configured by using the Java D
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.routeToRecipients(r -> r
|
||||
.applySequence(true)
|
||||
.ignoreSendFailures(true)
|
||||
@@ -861,7 +861,7 @@ The following example shows the equivalent router configured by using the Java D
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route(myCustomRouter())
|
||||
.get();
|
||||
}
|
||||
@@ -886,7 +886,7 @@ Alternately, you can route on data from the message payload, as the following ex
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route(String.class, p -> p.contains("foo") ? "fooChannel" : "barChannel")
|
||||
.get();
|
||||
}
|
||||
@@ -938,7 +938,7 @@ The following example shows the equivalent router configured in the Java DSL:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow routerFlow() {
|
||||
return IntegrationFlows.from("routingChannel")
|
||||
return IntegrationFlow.from("routingChannel")
|
||||
.route("payload.paymentType", r -> r
|
||||
.channelMapping("CASH", "cashPaymentChannel")
|
||||
.channelMapping("CREDIT", "authorizePaymentChannel")
|
||||
|
||||
@@ -290,7 +290,7 @@ The following example shows how to configure a RSocket inbound gateway with the
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow rsocketUpperCaseFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(RSockets.inboundGateway("/uppercase")
|
||||
.interactionModels(RSocketInteractionModel.requestChannel))
|
||||
.<Flux<String>, Mono<String>>transform((flux) -> flux.next().map(String::toUpperCase))
|
||||
@@ -332,7 +332,7 @@ The following example shows how to configure a RSocket outbound gateway with the
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow rsocketUpperCaseRequestFlow(ClientRSocketConnector clientRSocketConnector) {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Function.class)
|
||||
.handle(RSockets.outboundGateway("/uppercase")
|
||||
.interactionModel(RSocketInteractionModel.requestResponse)
|
||||
|
||||
@@ -552,7 +552,7 @@ public class SftpJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sftpInboundFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Sftp.inboundAdapter(this.sftpSessionFactory)
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("foo")
|
||||
@@ -763,7 +763,7 @@ This allows files retrieved from different directories to be downloaded to simil
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow flow() {
|
||||
return IntegrationFlows.from(Sftp.inboundAdapter(sf())
|
||||
return IntegrationFlow.from(Sftp.inboundAdapter(sf())
|
||||
.filter(new SftpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate"))
|
||||
.localDirectory(new File(tmpDir))
|
||||
.localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root")
|
||||
@@ -952,7 +952,7 @@ public class SftpJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sftpOutboundFlow() {
|
||||
return IntegrationFlows.from("toSftpChannel")
|
||||
return IntegrationFlow.from("toSftpChannel")
|
||||
.handle(Sftp.outboundAdapter(this.sftpSessionFactory, FileExistsMode.FAIL)
|
||||
.useTemporaryFileName(false)
|
||||
.remoteDirectory("/foo")
|
||||
@@ -1310,7 +1310,7 @@ public class SftpJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow sftpMGetFlow() {
|
||||
return IntegrationFlows.from("sftpMgetInputChannel")
|
||||
return IntegrationFlow.from("sftpMgetInputChannel")
|
||||
.handle(Sftp.outboundGateway(sftpSessionFactory(),
|
||||
AbstractRemoteFileOutboundGateway.Command.MGET, "payload")
|
||||
.options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE)
|
||||
|
||||
@@ -169,7 +169,7 @@ public class SmbJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow smbInboundFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(Smb.inboundAdapter(smbSessionFactory())
|
||||
.preserveTimestamp(true)
|
||||
.remoteDirectory("smbSource")
|
||||
@@ -375,7 +375,7 @@ public class SmbJavaApplication {
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow smbOutboundFlow() {
|
||||
return IntegrationFlows.from("toSmbChannel")
|
||||
return IntegrationFlow.from("toSmbChannel")
|
||||
.handle(Smb.outboundAdapter(smbSessionFactory(), FileExistsMode.REPLACE)
|
||||
.useTemporaryFileName(false)
|
||||
.fileNameExpression("headers['" + FileHeaders.FILENAME + "']")
|
||||
|
||||
@@ -288,7 +288,7 @@ public MessageSource<Integer> testingMessageSource() {
|
||||
return MockIntegration.mockMessageSource(1, 2, 3);
|
||||
}
|
||||
...
|
||||
StandardIntegrationFlow flow = IntegrationFlows
|
||||
StandardIntegrationFlow flow = IntegrationFlow
|
||||
.from(MockIntegration.mockMessageSource("foo", "bar", "baz"))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(out)
|
||||
|
||||
@@ -415,7 +415,7 @@ WebSocketInboundChannelAdapter webSocketInboundChannelAdapter =
|
||||
QueueChannel dynamicRequestsChannel = new QueueChannel();
|
||||
|
||||
IntegrationFlow serverFlow =
|
||||
IntegrationFlows.from(webSocketInboundChannelAdapter)
|
||||
IntegrationFlow.from(webSocketInboundChannelAdapter)
|
||||
.channel(dynamicRequestsChannel)
|
||||
.get();
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ The following example shows a simple implementation of a WebFlux endpoint:
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow inboundChannelAdapterFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(WebFlux.inboundChannelAdapter("/reactivePost")
|
||||
.requestMapping(m -> m.methods(HttpMethod.POST))
|
||||
.requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class))
|
||||
@@ -142,7 +142,7 @@ This way, we can implement https://en.wikipedia.org/wiki/Server-sent_events[Serv
|
||||
----
|
||||
@Bean
|
||||
public IntegrationFlow sseFlow() {
|
||||
return IntegrationFlows
|
||||
return IntegrationFlow
|
||||
.from(WebFlux.inboundGateway("/sse")
|
||||
.requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE)))
|
||||
.handle((p, h) -> Flux.just("foo", "bar", "baz"))
|
||||
|
||||
@@ -47,6 +47,9 @@ The `AggregatingMessageHandler` now does not split a `Collection<Message<?>>` re
|
||||
|
||||
See <<./aggregator.adoc#aggregator,Aggregator>> for more information.
|
||||
|
||||
The `IntegrationFlows` factory is now marked as deprecated in favor of the fluent API available in the `IntegrationFlow` interface itself.
|
||||
The factory class will be removed in the future releases.
|
||||
|
||||
[[x6.0-http]]
|
||||
=== HTTP Changes
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ The equivalent configuration for the gateways shown in <<webservices-namespace>>
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow inbound() {
|
||||
return IntegrationFlows.from(Ws.simpleInboundGateway()
|
||||
return IntegrationFlow.from(Ws.simpleInboundGateway()
|
||||
.id("simpleGateway"))
|
||||
...
|
||||
.get();
|
||||
@@ -205,7 +205,7 @@ IntegrationFlow outboundMarshalled() {
|
||||
----
|
||||
@Bean
|
||||
IntegrationFlow inboundMarshalled() {
|
||||
return IntegrationFlows.from(Ws.marshallingInboundGateway()
|
||||
return IntegrationFlow.from(Ws.marshallingInboundGateway()
|
||||
.marshaller(someMarshaller())
|
||||
.unmarshaller(someUnmarshalller())
|
||||
.id("marshallingGateway"))
|
||||
|
||||
@@ -193,7 +193,7 @@ The Inbound Channel Adapter for ZeroMQ Java DSL is:
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
IntegrationFlows.from(
|
||||
IntegrationFlow.from(
|
||||
ZeroMq.inboundChannelAdapter(this.context, SocketType.SUB)
|
||||
.connectUrl("tcp://localhost:9000")
|
||||
.topics("someTopic")
|
||||
|
||||
Reference in New Issue
Block a user