– Start
点击此处观看本系列配套视频
废话少说,直接上代码。
package shangbo.kafka.example7;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.SendResult;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
public class App {
@SuppressWarnings({ "resource", "unchecked" })
public static void main(String[] args) {
ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
// 使用 kafkaTemplate 发送消息
KafkaTemplate<String, String> kafkaTemplate = c

本文简要介绍如何在Spring应用中整合Kafka进行消息发送。通过代码示例展示具体实现过程,辅助以配套视频教程,帮助读者快速掌握Kafka消息发送功能。
最低0.47元/天 解锁文章
2353

被折叠的 条评论
为什么被折叠?



