use of org.springframework.integration.dsl.IntegrationFlow in project spring-integration-samples by spring-projects.
the class Application method addAnotherListenerForTopics.
public void addAnotherListenerForTopics(String... topics) {
Map<String, Object> consumerProperties = kafkaProperties.buildConsumerProperties();
// change the group id so we don't revoke the other partitions.
consumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG, consumerProperties.get(ConsumerConfig.GROUP_ID_CONFIG) + "x");
IntegrationFlow flow = IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(new DefaultKafkaConsumerFactory<String, String>(consumerProperties), topics)).channel("fromKafka").get();
this.flowContext.registration(flow).register();
}
use of org.springframework.integration.dsl.IntegrationFlow in project spring-integration-samples by spring-projects.
the class Application method addAnotherListenerForTopics.
public void addAnotherListenerForTopics(String... topics) {
Map<String, Object> consumerProperties = kafkaProperties.buildConsumerProperties();
// change the group id so we don't revoke the other partitions.
consumerProperties.put(ConsumerConfig.GROUP_ID_CONFIG, consumerProperties.get(ConsumerConfig.GROUP_ID_CONFIG) + "x");
IntegrationFlow flow = IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(new DefaultKafkaConsumerFactory<String, String>(consumerProperties), topics)).channel("fromKafka").get();
this.flowContext.registration(flow).register();
}
use of org.springframework.integration.dsl.IntegrationFlow in project spring-integration by spring-projects.
the class ManualFlowTests method testWithAnonymousMessageProducerSpecStart.
@Test
public void testWithAnonymousMessageProducerSpecStart() {
final AtomicBoolean started = new AtomicBoolean();
class MyProducer extends MessageProducerSupport {
@Override
protected void doStart() {
started.set(true);
super.doStart();
}
}
class MyProducerSpec extends MessageProducerSpec<MyProducerSpec, MyProducer> {
MyProducerSpec(MyProducer producer) {
super(producer);
}
}
MyProducerSpec spec = new MyProducerSpec(new MyProducer());
QueueChannel channel = new QueueChannel();
IntegrationFlow flow = IntegrationFlows.from(spec.id("foo")).channel(channel).get();
this.integrationFlowContext.registration(flow).register();
assertTrue(started.get());
}
use of org.springframework.integration.dsl.IntegrationFlow in project spring-integration by spring-projects.
the class ReactiveStreamsTests method testFromPublisher.
@Test
public void testFromPublisher() {
Flux<Message<?>> messageFlux = Flux.just("1,2,3,4").map(v -> v.split(",")).flatMapIterable(Arrays::asList).map(Integer::parseInt).log("org.springframework.integration.flux").map(GenericMessage<Integer>::new);
QueueChannel resultChannel = new QueueChannel();
IntegrationFlow integrationFlow = IntegrationFlows.from(messageFlux).log("org.springframework.integration.flux2").<Integer, Integer>transform(p -> p * 2).channel(resultChannel).get();
this.integrationFlowContext.registration(integrationFlow).register();
for (int i = 0; i < 4; i++) {
Message<?> receive = resultChannel.receive(10000);
assertNotNull(receive);
assertEquals((i + 1) * 2, receive.getPayload());
}
}
use of org.springframework.integration.dsl.IntegrationFlow in project spring-integration by spring-projects.
the class StandardIntegrationFlowContext method register.
private void register(StandardIntegrationFlowRegistrationBuilder builder) {
IntegrationFlow integrationFlow = builder.integrationFlowRegistration.getIntegrationFlow();
String flowId = builder.integrationFlowRegistration.getId();
if (flowId == null) {
flowId = generateBeanName(integrationFlow, null);
builder.id(flowId);
} else if (this.registry.containsKey(flowId)) {
throw new IllegalArgumentException("An IntegrationFlow '" + this.registry.get(flowId) + "' with flowId '" + flowId + "' is already registered.\n" + "An existing IntegrationFlowRegistration must be destroyed before overriding.");
}
IntegrationFlow theFlow = (IntegrationFlow) registerBean(integrationFlow, flowId, null);
builder.integrationFlowRegistration.setIntegrationFlow(theFlow);
final String theFlowId = flowId;
builder.additionalBeans.forEach((key, value) -> registerBean(key, value, theFlowId));
if (builder.autoStartup) {
builder.integrationFlowRegistration.start();
}
this.registry.put(flowId, builder.integrationFlowRegistration);
}
Aggregations