|
|
@@ -1,6 +1,7 @@
|
|
|
package zs.payment.messages;
|
|
|
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.kafka.core.KafkaTemplate;
|
|
|
@@ -9,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|
|
/**
|
|
|
* 生产者组件
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class KafkaProducer {
|
|
|
@Autowired
|
|
|
@@ -23,6 +25,7 @@ public class KafkaProducer {
|
|
|
public void sendMessage(String topicName,String message) {
|
|
|
// 发送到默认分区(轮询)
|
|
|
kafkaTemplate.send(topicName, message);
|
|
|
- System.out.println(">>> 生产者发送消息: " + message);
|
|
|
+ log.info("product send message to topic:{},message:{}" , topicName , message);
|
|
|
+
|
|
|
}
|
|
|
}
|