/** * 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); }
/** * Populate the provided {@link AbstractMessageRouter} implementation to the * current integration flow position. * In addition accept options for the integration endpoint using {@link GenericEndpointSpec}. * @param router the {@link AbstractMessageRouter} to populate. * @param endpointConfigurer the {@link Consumer} to provide integration endpoint options. * @param <R> the {@link AbstractMessageRouter} type. * @return the current {@link IntegrationFlowDefinition}. */ public <R extends AbstractMessageRouter> B route(R router, Consumer<GenericEndpointSpec<R>> endpointConfigurer) { return handle(router, endpointConfigurer); }
@Bean public IntegrationFlow failure() { return f -> f .handle(m -> this.failed = m); }
@Bean public IntegrationFlow success() { return f -> f .handle(m -> this.successful = m); }
@Bean public IntegrationFlow upperCase() { return f -> f .<String>handle((p, h) -> p.toUpperCase()); }
@Bean public IntegrationFlow recipient2() { return f -> f .<AtomicReference<String>>handle((p, h) -> { p.set(p.get() + "Hello "); return p; }) .channel("recipientListOrderResult"); }
@Bean public IntegrationFlow advised() { return f -> f.handle((GenericHandler<String>) (payload, headers) -> { if (payload.equals("good")) { return null; } else { throw new RuntimeException("some failure"); } }, c -> c.advice(expressionAdvice())); }
@Bean public IntegrationFlow wireTapFlow2() { return f -> f .wireTap("tapChannel", wt -> wt.selector(m -> m.getPayload().equals("foo"))) .handle(loggingMessageHandler()); }
@Bean public IntegrationFlow httpProxyErrorFlow() { return f -> f .transform(Throwable::getCause) .<HttpClientErrorException>handle((p, h) -> new ResponseEntity<>(p.getResponseBodyAsString(), p.getStatusCode())); }
@Bean public IntegrationFlow gatewaySingleQueryExpressionFlow() { return f -> f .handle(queryExpressionOutboundGateway(true)) .channel(getResultChannel()); }
@Bean public IntegrationFlow gatewayQueryFunctionFlow() { return f -> f .handle(queryFunctionOutboundGateway(true)) .channel(getResultChannel()); }
@Bean public IntegrationFlow gatewayCollectionNameFunctionFlow() { return f -> f .handle(collectionNameFunctionOutboundGateway(true)) .channel(getResultChannel()); }
@Bean public IntegrationFlow gatewayCollectionCallbackFlow() { return f -> f .handle(collectionCallbackOutboundGateway( (collection, requestMessage) -> collection.countDocuments())) .channel(getResultChannel()); }
@Bean public IntegrationFlow outboundAdapterFlow(EntityManagerFactory entityManagerFactory) { return f -> f .handle(Jpa.outboundAdapter(entityManagerFactory) .entityClass(StudentDomain.class) .persistMode(PersistMode.PERSIST), e -> e.transactional(true)); }
@Bean public IntegrationFlow updatingGatewayFlow(EntityManagerFactory entityManagerFactory) { return f -> f .handle(Jpa.updatingGateway(entityManagerFactory), e -> e.transactional(true)) .channel(c -> c.queue("persistResults")); }
@Bean public IntegrationFlow webFluxFlowWithReplyPayloadToFlux() { return f -> f .handle(WebFlux.outboundGateway("http://www.springsource.org/spring-integration") .httpMethod(HttpMethod.GET) .replyPayloadToFlux(true) .expectedResponseType(String.class), e -> e.id("webFluxWithReplyPayloadToFlux")); }
@Bean public IntegrationFlow clientTcpFlow() { return f -> f .handle(tcpOut(), e -> e.advice(testAdvice())) .transform(Transformers.objectToString()); }
@Bean public IntegrationFlow jmsOutboundGatewayFlow() { return f -> f.handle(Jms.outboundGateway(cachingConnectionFactory()) .replyContainer(c -> c.idleReplyContainerTimeout(10)) .requestDestination("jmsPipelineTest"), e -> e.id("jmsOutboundGateway")); }
@Bean public IntegrationFlow retrievingGatewayFlow(EntityManagerFactory entityManagerFactory) { return f -> f .handle(Jpa.retrievingGateway(entityManagerFactory) .jpaQuery("from Student s where s.id = :id") .expectSingleResult(true) .parameterExpression("id", "headers[payloadId]")) .channel(c -> c.queue("retrieveResults")); }
@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(); }