use of org.springframework.integration.dsl.IntegrationFlowBuilder in project spring-cloud-stream by spring-cloud.
the class FunctionConfiguration method integrationFlowFromProvidedSupplier.
@SuppressWarnings({ "rawtypes", "unchecked" })
private IntegrationFlowBuilder integrationFlowFromProvidedSupplier(Supplier<?> supplier, Publisher<Object> beginPublishingTrigger, PollableBean pollable, GenericApplicationContext context, TaskScheduler taskScheduler, ProducerProperties producerProperties, String bindingName) {
IntegrationFlowBuilder integrationFlowBuilder;
boolean splittable = pollable != null && (boolean) AnnotationUtils.getAnnotationAttributes(pollable).get("splittable");
FunctionInvocationWrapper function = (supplier instanceof PartitionAwareFunctionWrapper) ? (FunctionInvocationWrapper) ((PartitionAwareFunctionWrapper) supplier).function : (FunctionInvocationWrapper) supplier;
boolean reactive = FunctionTypeUtils.isPublisher(function.getOutputType());
if (pollable == null && reactive) {
Publisher publisher = (Publisher) supplier.get();
publisher = publisher instanceof Mono ? ((Mono) publisher).delaySubscription(beginPublishingTrigger).map(this::wrapToMessageIfNecessary) : ((Flux) publisher).delaySubscription(beginPublishingTrigger).map(this::wrapToMessageIfNecessary);
integrationFlowBuilder = IntegrationFlows.from(publisher);
// see https://github.com/spring-cloud/spring-cloud-stream/issues/1863 for details about the following code
// will keep AC alive
taskScheduler.schedule(() -> {
}, Instant.now());
} else {
// implies pollable
boolean autoStartup = producerProperties != null ? producerProperties.isAutoStartup() : true;
integrationFlowBuilder = IntegrationFlows.fromSupplier(supplier, spca -> spca.id(bindingName + "_spca").autoStartup(autoStartup));
// only apply the PollableBean attributes if this is a reactive function.
if (splittable && reactive) {
integrationFlowBuilder = integrationFlowBuilder.split();
}
}
return integrationFlowBuilder;
}
use of org.springframework.integration.dsl.IntegrationFlowBuilder in project spring-integration by spring-projects.
the class AmqpTests method testTemplateChannelTransacted.
@Test
public void testTemplateChannelTransacted() {
IntegrationFlowBuilder flow = IntegrationFlows.from(Amqp.channel("testTemplateChannelTransacted", this.rabbitConnectionFactory).autoStartup(false).templateChannelTransacted(true));
assertTrue(TestUtils.getPropertyValue(flow, "currentMessageChannel.amqpTemplate.transactional", Boolean.class));
}
Aggregations