修改kafka配置
This commit is contained in:
@@ -10,12 +10,8 @@ import org.springframework.beans.BeanUtils;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.kafka.annotation.KafkaListener;
|
import org.springframework.kafka.annotation.KafkaListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName CorpusProcessKafkaConsumer
|
* @ClassName CorpusProcessKafkaConsumer
|
||||||
@@ -26,7 +22,6 @@ import java.util.Date;
|
|||||||
**/
|
**/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RestController
|
|
||||||
public class CorpusProcessKafkaConsumer {
|
public class CorpusProcessKafkaConsumer {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -34,11 +29,10 @@ public class CorpusProcessKafkaConsumer {
|
|||||||
|
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
@GetMapping("corpusProcessKafkaConsumer")
|
@KafkaListener(topics = "${spring.kafka.topic}", groupId = "${spring.kafka.group}")
|
||||||
// @KafkaListener(topics = "aicorpus-telephone", groupId = "test-group")
|
public void listen(String message) {
|
||||||
public void listen(@RequestBody String message) {
|
|
||||||
try {
|
try {
|
||||||
log.info("Received message: {}" , message);
|
log.info("CorpusProcessKafkaConsumer Received message: {}" , message);
|
||||||
|
|
||||||
AicorpusTelephoneDTO aicorpusTelephone = objectMapper.readValue(message, AicorpusTelephoneDTO.class);
|
AicorpusTelephoneDTO aicorpusTelephone = objectMapper.readValue(message, AicorpusTelephoneDTO.class);
|
||||||
log.info("aicorpusTelephone categoryCode:{}, display: {}" ,aicorpusTelephone.getCategoryCode(), aicorpusTelephone.getDisplay());
|
log.info("aicorpusTelephone categoryCode:{}, display: {}" ,aicorpusTelephone.getCategoryCode(), aicorpusTelephone.getDisplay());
|
||||||
|
|||||||
Reference in New Issue
Block a user