/** * Populate an {@link org.springframework.integration.channel.FixedSubscriberChannel} instance * at the current {@link IntegrationFlow} chain position. * The provided {@code messageChannelName} is used for the bean registration. * @param messageChannelName the bean name to use. * @return the current {@link IntegrationFlowDefinition}. */ public B fixedSubscriberChannel(String messageChannelName) { return channel(new FixedSubscriberChannelPrototype(messageChannelName)); }
/** * Populate a {@link MessageChannel} instance * at the current {@link IntegrationFlow} chain position using the {@link MessageChannelSpec} * fluent API. * @param messageChannelSpec the {@link MessageChannelSpec} to use. * @return the current {@link IntegrationFlowDefinition}. * @see org.springframework.integration.dsl.MessageChannels */ public B channel(MessageChannelSpec<?, ?> messageChannelSpec) { Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null"); return channel(messageChannelSpec.get()); }
/** * 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 a {@link MessageChannel} instance * at the current {@link IntegrationFlow} chain position using the {@link Channels} * factory fluent API. * @param channels the {@link Function} to use. * @return the current {@link IntegrationFlowDefinition}. */ public B channel(Function<Channels, MessageChannelSpec<?, ?>> channels) { Assert.notNull(channels, "'channels' must not be null"); return channel(channels.apply(new Channels())); }
@Bean public IntegrationFlow recipient2() { return f -> f .<AtomicReference<String>>handle((p, h) -> { p.set(p.get() + "Hello "); return p; }) .channel("recipientListOrderResult"); }
@Bean public IntegrationFlow publishSubscribeAggregateFlow() { return flow -> flow .aggregate(a -> a.outputProcessor(g -> g.getMessages() .stream() .map(m -> (String) m.getPayload()) .collect(Collectors.joining(" ")))) .channel(MessageChannels.queue("subscriberAggregateResult")); }
@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 decodingFlow() { return f -> f .transform(Transformers.decoding(new MyCodec(), m -> Integer.class)) .channel("codecReplyChannel"); }
@Bean public IntegrationFlow gatewaySingleQueryFlow() { return f -> f .handle(queryOutboundGateway("{name: 'Xavi'}", true)) .channel(getResultChannel()); }
@Bean public IntegrationFlow gatewayCollectionNameFunctionFlow() { return f -> f .handle(collectionNameFunctionOutboundGateway(true)) .channel(getResultChannel()); }
@Bean public IntegrationFlow scriptFilter() { return f -> f.filter(Scripts.processor(this.filterScript), e -> e.discardChannel("discardChannel")) .channel(results()); }
@Bean public IntegrationFlow delayFlow() { return flow -> flow .delay(GROUP_ID, e -> e .messageStore(messageGroupStore) .id("delayer")) .channel(MessageChannels.queue("delayedResults")); }
@Bean public IntegrationFlow gatewayCollectionCallbackFlow() { return f -> f .handle(collectionCallbackOutboundGateway( (collection, requestMessage) -> collection.countDocuments())) .channel(getResultChannel()); }
@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 routerAsNonLastFlow() { return f -> f .<String, String>route(p -> p, r -> r.resolutionRequired(false) .defaultOutputToParentFlow()) .channel(MessageChannels.queue("routerAsNonLastDefaultOutputChannel")); }
@Bean public IntegrationFlow flow1() { return f -> f .fixedSubscriberChannel("integerChannel") .transform("payload.toString()") .channel(Jms.pollableChannel("flow1QueueChannel", jmsConnectionFactory()) .destination("flow1QueueChannel")); }
@Bean public IntegrationFlow scriptTransformer() { return f -> f .transform(Scripts.processor("scripts/TestTransformerScript.rb") .lang("ruby") .variable("foo", "bar")) .channel(results()); }
@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 scriptFilter() { return f -> f .filter(Scripts.processor(scriptResource()) .lang("groovy"), e -> e.discardChannel("discardChannel")) .channel(c -> c.queue("results")); }