/** * Create an {@link IntegrationFlow} with a {@link ChunkProcessorChunkHandler} * configured as a service activator listening to the input channel and replying * on the output channel. * * @return the integration flow */ @SuppressWarnings({"unchecked", "rawtypes"}) public IntegrationFlow build() { Assert.notNull(this.itemWriter, "An ItemWriter must be provided"); Assert.notNull(this.inputChannel, "An InputChannel must be provided"); Assert.notNull(this.outputChannel, "An OutputChannel must be provided"); if(this.itemProcessor == null) { this.itemProcessor = new PassThroughItemProcessor(); } SimpleChunkProcessor<I, O> chunkProcessor = new SimpleChunkProcessor<>(this.itemProcessor, this.itemWriter); ChunkProcessorChunkHandler<I> chunkProcessorChunkHandler = new ChunkProcessorChunkHandler<>(); chunkProcessorChunkHandler.setChunkProcessor(chunkProcessor); return IntegrationFlows .from(this.inputChannel) .handle(chunkProcessorChunkHandler, SERVICE_ACTIVATOR_METHOD_NAME) .channel(this.outputChannel) .get(); }
.from(this.inputChannel) .handle(stepExecutionRequestHandler, SERVICE_ACTIVATOR_METHOD_NAME) .channel(this.outputChannel) .get(); IntegrationFlowContext integrationFlowContext = this.beanFactory.getBean(IntegrationFlowContext.class); integrationFlowContext.registration(standardIntegrationFlow) .autoStartup(false) .register();
partitionHandler.setReplyChannel(replies); StandardIntegrationFlow standardIntegrationFlow = IntegrationFlows .from(this.inputChannel) .aggregate(aggregatorSpec -> aggregatorSpec.processor(partitionHandler)) .channel(replies) .get(); IntegrationFlowContext integrationFlowContext = this.beanFactory.getBean(IntegrationFlowContext.class); integrationFlowContext.registration(standardIntegrationFlow) .autoStartup(false) .register();
@Bean public IntegrationFlow routeFlow() { return IntegrationFlows.from("routerInput") .<Integer, Boolean>route(p -> p % 2 == 0, m -> m.channelMapping(true, "evenChannel") .subFlowMapping(false, f -> f.<Integer>handle((p, h) -> p * 3)) .defaultOutputToParentFlow()) .channel(MessageChannels.queue("oddChannel")) .get(); }
@Bean public IntegrationFlow supplierFlow2() { return IntegrationFlows.from(() -> "foo", c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1))) .<String, String>transform(String::toUpperCase) .channel("suppliedChannel2") .get(); }
@Bean public Publisher<Message<Integer>> pollableReactiveFlow() { return IntegrationFlows .from("inputChannel") .split(s -> s.delimiters(",")) .<String, Integer>transform(Integer::parseInt) .channel(MessageChannels.queue()) .log() .toReactivePublisher(); }
/** * Populate the {@link MessageProducerSupport} object to the {@link IntegrationFlowBuilder} chain * using the fluent API from the {@link MessageProducerSpec}. * The {@link org.springframework.integration.dsl.IntegrationFlow} {@code startMessageProducer}. * @param messageProducerSpec the {@link MessageProducerSpec} to use. * @return new {@link IntegrationFlowBuilder}. * @see MessageProducerSpec */ public static IntegrationFlowBuilder from(MessageProducerSpec<?, ?> messageProducerSpec) { return from(messageProducerSpec.get(), registerComponents(messageProducerSpec)); }
/** * Populate the {@link MessagingGatewaySupport} object to the {@link IntegrationFlowBuilder} chain * using the fluent API from the {@link MessagingGatewaySpec}. * The {@link org.springframework.integration.dsl.IntegrationFlow} {@code startMessagingGateway}. * @param inboundGatewaySpec the {@link MessagingGatewaySpec} to use. * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(MessagingGatewaySpec<?, ?> inboundGatewaySpec) { return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec)); }
private static IntegrationFlowBuilder registerComponents(Object spec) { if (spec instanceof ComponentsRegistration) { return new IntegrationFlowBuilder() .addComponents(((ComponentsRegistration) spec).getComponentsToRegister()); } return null; }
@Override public MessageChannel getInputChannel() { assertTargetIntegrationFlow(); return this.targetIntegrationFlow.getInputChannel(); }