package org.ts.ddcs.kafka;

import com.alibaba.fastjson.JSONObject;
import org.ts.ddcs.Log.LogHelper;
import org.ts.ddcs.Worker.DataProcessHolder;
import org.ts.ddcs.utils.GBConstants;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class KafkaMessageListener {

//    @KafkaListener(topics = "${rabbit.config.queue.waitingToProcessDatagram}", containerFactory = "kafkaListenerContainerFactory")
    public void process(List<ConsumerRecord<String, String>> records) throws Exception {
        try {
            for (ConsumerRecord<String, String> record : records) {
                LogHelper.info("kafka " + record.topic() + " " + record.partition() + " " + record.value());
                String body = record.value();
                DataProcessHolder.newInstance().dataProcess.SubmitSw2014DataGramTask(body);
            }
        } catch (Exception e) {
            LogHelper.error(e);
        }
    }
}
