/** * Populate a {@link ServiceActivatingHandler} for the * {@link org.springframework.integration.handler.MethodInvokingMessageProcessor} * to invoke the discovered {@code method} for provided {@code service} at runtime. * @param service the service object to use. * @return the current {@link IntegrationFlowDefinition}. */ public B handle(Object service) { return handle(service, null); }
/** * Add a {@value IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME} bean into this flow * definition as a terminal operator. * @return The {@link IntegrationFlow} instance based on this definition. * @since 5.1 */ public IntegrationFlow nullChannel() { return channel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME) .get(); }
/** * Populate the {@code MessageTransformingHandler} for the {@link MethodInvokingTransformer} * to invoke the discovered service method at runtime. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @see ExpressionEvaluatingTransformer */ public B transform(Object service) { return transform(service, null); }
@Bean public IntegrationFlow publishSubscribeFlow() { return flow -> flow .publishSubscribeChannel(s -> s .applySequence(true) .subscribe(f -> f .handle((p, h) -> "Hello") .channel("publishSubscribeAggregateFlow.input")) .subscribe(f -> f .handle((p, h) -> "World!") .channel("publishSubscribeAggregateFlow.input")) ); }
@Bean public IntegrationFlow routerTwoSubFlows() { return f -> f .split() .<Integer, Boolean>route(p -> p % 2 == 0, m -> m .subFlowMapping(true, sf -> sf.<Integer>handle((p, h) -> p * 2)) .subFlowMapping(false, sf -> sf.<Integer>handle((p, h) -> p * 3))) .aggregate() .channel(MessageChannels.queue("routerTwoSubFlowsOutput")); }
@Bean @SuppressWarnings("rawtypes") public IntegrationFlow splitResequenceFlow(MessageChannel executorChannel) { return f -> f.enrichHeaders(s -> s.header("FOO", "BAR")) .split("testSplitterData", "buildList", c -> c.applySequence(false)) .channel(executorChannel) .split(Message.class, Message::getPayload, c -> c.applySequence(false)) .channel(MessageChannels.executor(taskExecutor())) .split(s -> s .applySequence(false) .delimiters(",")) .channel(MessageChannels.executor(taskExecutor())) .<String, Integer>transform(Integer::parseInt) .enrichHeaders(h -> h.headerFunction(IntegrationMessageHeaderAccessor.SEQUENCE_NUMBER, Message::getPayload)) .resequence(r -> r.releasePartialSequences(true).correlationExpression("'foo'")) .headerFilter("foo", false); }
@Bean public IntegrationFlow sendToKafkaFlow() { return f -> f.<String>split(p -> Stream.generate(() -> p).limit(101).iterator(), null) .publishSubscribeChannel(c -> c .subscribe(sf -> sf.handle(kafkaMessageHandler(producerFactory(), TEST_TOPIC), e -> e.id("kafkaProducer"))) .subscribe(sf -> sf.handle(kafkaMessageHandler(producerFactory(), TEST_TOPIC3), e -> e.id("kafkaProducer3"))) ); }
@Bean public IntegrationFlow routeSubflowWithoutReplyToMainFlow() { return f -> f .<String, Boolean>route("BOO"::equals, m -> m .resolutionRequired(false) .subFlowMapping(true, sf -> sf .transform(String.class, String::toLowerCase) .channel(MessageChannels.queue("routerSubflowResult"))) .defaultSubFlowMapping(sf -> sf.channel("defaultOutputChannel"))); }
@Bean public IntegrationFlow flow1() { return f -> f .fixedSubscriberChannel("integerChannel") .transform("payload.toString()") .channel(Jms.pollableChannel("flow1QueueChannel", jmsConnectionFactory()) .destination("flow1QueueChannel")); }
/** * Populate the {@link MethodInvokingSplitter} to evaluate the discovered * {@code method} of the {@code service} at runtime. * @param service the service to use. * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSplitter */ public B split(Object service) { return split(service, null); }
/** * Populate the {@link MethodInvokingRouter} for the method * of the provided service and its method with default options. * @param service the service to use. * @param methodName the method to invoke. * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingRouter */ public B route(Object service, String methodName) { return route(service, methodName, null); }
@Bean public IntegrationFlow pojoTransformFlow() { return f -> f .enrichHeaders(h -> h .header("Foo", "Bar") .advice(idempotentReceiverInterceptor(), requestHandlerAdvice())) .transform(new PojoTransformer()); }
/** * Populate a {@link MessageFilter} with {@link MethodInvokingSelector} for the * method of the provided service. * @param service the service to use. * @param methodName the method to invoke * @return the current {@link IntegrationFlowDefinition}. * @see MethodInvokingSelector */ public B filter(Object service, String methodName) { return filter(service, methodName, null); }