nvps增强检索工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

package com.bw.search.process;
import java.util.Map;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.bw.search.cache.ConfigCache;
import com.bw.search.entity.Constants;
import lombok.extern.slf4j.Slf4j;
/**
* 接口响应结果操作类
* @author jian.mao
* @date 2023年7月6日
* @description
*/
@Component
@Slf4j
public class ResultSendQueue {
/**
* kafka读取结果写入队列
* @param message
*/
@KafkaListener(topics = "#{kafkaConfig.getKafkaTopic()}")
public void consumeMessage(String message) {
// 处理接收到的消息逻辑
try {
Map<String, Object> result = JSONObject.parseObject(message);
String key = result.get(Constants.ID).toString();
ConfigCache.baseResult.put(key, result);
ConfigCache.searchResult.put(key, result);
log.info("消费知识:{}",key);
} catch (Exception e) {
log.error("结果集json转换失败,result:{},\n",message,e);
}
}
}