package com.energy.manage.service.service.kafka.customer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
//@Component
public class KafkaListenerService {

//    // 接收消息
//    @KafkaListener(topics = "test",groupId = "${spring.kafka.consumer.groupId}",
//            containerFactory = "kafkaListenerContainerFactory",
//            concurrency = "1",
//            properties = {"${spring.kafka.consumer.autoOffsetReset}"})
//    public void processMessage1(List<ConsumerRecord<String, String>> records, Acknowledgment ack) {
//        for (ConsumerRecord<String, String> record : records) {
//            log.info("topic_test 消费了： Topic:" + record.topic() + ",Message:" + record.value());
//            //手动提交偏移量
//            ack.acknowledge();
//        }
//    }
//
//
//    // 接收消息
//    @KafkaListener(topics = "abc",groupId = "${spring.kafka.consumer.groupId}",
//            containerFactory = "kafkaListenerContainerFactory",
//            concurrency = "1",
//            properties = {"${spring.kafka.consumer.autoOffsetReset}"})
//    public void processMessage2(List<ConsumerRecord<String, String>> records, Acknowledgment ack) {
//        for (ConsumerRecord<String, String> record : records) {
//            log.info("topic_test 消费了： Topic:" + record.topic() + ",Message:" + record.value());
//            //手动提交偏移量
//            ack.acknowledge();
//        }
//    }



}
