@Bean public Publisher<Message<String>> fixedSubscriberChannelFlow() { return IntegrationFlows .from("fixedSubscriberChannel", true) .log() .toReactivePublisher(); }
@Bean public Publisher<Message<String>> singleChannelFlow() { return IntegrationFlows .from(MessageChannels.direct("singleChannel")) .log() .toReactivePublisher(); }
@Bean public Publisher<Message<String>> reactiveFlow() { return IntegrationFlows .from(() -> new GenericMessage<>("a,b,c,d,e,f"), e -> e.poller(p -> p.trigger(ctx -> this.invoked.getAndSet(true) ? null : new Date())) .autoStartup(false) .id("reactiveStreamsMessageSource")) .split(String.class, p -> p.split(",")) .log() .toReactivePublisher(); }
@Bean public Publisher<Message<Integer>> pollableReactiveFlow() { return IntegrationFlows .from("inputChannel") .split(s -> s.delimiters(",")) .<String, Integer>transform(Integer::parseInt) .channel(MessageChannels.queue()) .log() .toReactivePublisher(); }
/** * Add a {@link Function} bean to the end of an integration flow. * The name of the bean must be provided via `spring.cloud.stream.function.definition` property. * <p> * NOTE: If this method returns true, the integration flow is now represented * as a Reactive Streams {@link Publisher} bean. * </p> * @param flowBuilder instance of the {@link IntegrationFlowBuilder} representing * the current state of the integration flow * @param outputChannel channel where the output of a function will be sent * @param functionName the function name to use * @return true if {@link Function} was located and added and false if it wasn't. */ public <I,O> boolean andThenFunction(IntegrationFlowBuilder flowBuilder, MessageChannel outputChannel, StreamFunctionProperties functionProperties) { return andThenFunction(flowBuilder.toReactivePublisher(), outputChannel, functionProperties); }
@Bean public Publisher<Message<String>> publisher() { return IntegrationFlows .from(() -> new GenericMessage<>(Math.random()), e -> e.poller(p -> p.trigger(ctx -> this.invoked.getAndSet(true) ? null : new Date()) .maxMessagesPerPoll(this.elements))) .channel(reactiveChannel()) .toReactivePublisher(); }
@Bean public Publisher<Message<String>> vanillaSource() { return IntegrationFlows .from(() -> new GenericMessage<>("foo"), e -> e.poller(p -> p.fixedDelay(1))) .toReactivePublisher(); }
private Publisher<Message<String>> getPublisher() { return IntegrationFlows .from("input") .channel(reactiveChannel()) .toReactivePublisher(); }
@Bean public Publisher<Message<String>> reactiveFlow() { return IntegrationFlows .from(() -> new GenericMessage<>("a,b,c,d,e,f"), e -> e.poller(p -> p.trigger(ctx -> this.invoked.getAndSet(true) ? null : new Date())) .autoStartup(false) .id("reactiveSteamsMessageSource")) .split(String.class, p -> p.split(",")) .toReactivePublisher(); }
@Bean public Publisher<Message<Integer>> pollableReactiveFlow() { return IntegrationFlows .from("inputChannel") .split(s -> s.delimiters(",")) .<String, Integer>transform(Integer::parseInt) .channel(Channels::queue) .toReactivePublisher(); }
private SubscribableChannel postProcessOutboundChannelForFunction(MessageChannel outputChannel, ProducerProperties producerProperties) { if (this.integrationFlowFunctionSupport != null) { Publisher<?> publisher = MessageChannelReactiveUtils.toPublisher(outputChannel); // If the app has an explicit Supplier bean defined, make that as the publisher if (this.integrationFlowFunctionSupport.containsFunction(Supplier.class)) { IntegrationFlowBuilder integrationFlowBuilder = IntegrationFlows.from(outputChannel).bridge(); publisher = integrationFlowBuilder.toReactivePublisher(); } if (this.integrationFlowFunctionSupport.containsFunction(Function.class, this.streamFunctionProperties.getDefinition())) { DirectChannel actualOutputChannel = new DirectChannel(); if (outputChannel instanceof AbstractMessageChannel) { moveChannelInterceptors((AbstractMessageChannel) outputChannel, actualOutputChannel); } this.integrationFlowFunctionSupport.andThenFunction(publisher, actualOutputChannel, this.streamFunctionProperties); return actualOutputChannel; } } return (SubscribableChannel) outputChannel; }