use of org.springframework.kafka.core.DefaultKafkaConsumerFactory 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.kafka.core.DefaultKafkaConsumerFactory in project tutorials by eugenp.
the class KafkaConsumerConfig method greetingConsumerFactory.
public ConsumerFactory<String, Greeting> greetingConsumerFactory() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "greeting");
return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(Greeting.class));
}
use of org.springframework.kafka.core.DefaultKafkaConsumerFactory 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.kafka.core.DefaultKafkaConsumerFactory in project xm-ms-entity by xm-online.
the class ApplicationStartup method createSystemConsumer.
private void createSystemConsumer(String name, MessageListener<String, String> consumeEvent) {
log.info("Creating kafka consumer for topic {}", name);
ContainerProperties containerProps = new ContainerProperties(name);
Map<String, Object> props = kafkaProperties.buildConsumerProperties();
if (name.equals(applicationProperties.getKafkaSystemTopic())) {
props.put(ConsumerConfig.GROUP_ID_CONFIG, UUID.randomUUID().toString());
}
ConsumerFactory<String, String> factory = new DefaultKafkaConsumerFactory<>(props);
ConcurrentMessageListenerContainer<String, String> container = new ConcurrentMessageListenerContainer<>(factory, containerProps);
container.setupMessageListener(consumeEvent);
container.start();
log.info("Successfully created kafka consumer for topic {}", name);
}
use of org.springframework.kafka.core.DefaultKafkaConsumerFactory in project eventapis by kloiasoft.
the class EventListenConfiguration method startOperations.
private void startOperations() {
Map<String, Object> consumerProperties = eventApisConfiguration.getEventBus().buildConsumerProperties();
DefaultKafkaConsumerFactory<String, Operation> operationConsumerFactory = new DefaultKafkaConsumerFactory<>(consumerProperties, new StringDeserializer(), new JsonDeserializer<>(Operation.class));
ContainerProperties operationContainerProperties = new ContainerProperties(Operation.OPERATION_EVENTS);
operationContainerProperties.setMessageListener(new MultipleEventMessageListener(eventMessageListeners));
operationListenerContainer = new ConcurrentMessageListenerContainer<>(operationConsumerFactory, operationContainerProperties);
operationListenerContainer.setBeanName("emon-operations");
operationListenerContainer.start();
}
Aggregations