使用LokiClient

详细使用实例可查看 loki-testopen in new windowClientController.java

请求参数

参数名是否必填备注
topic主题
tag标签
message消息内容
deliveryTimestamp延迟时间
keyskey

全依赖注入

RocketMQ

依赖注入

@Resource
private RocketClient rocketClient;

使用

ProducerRecord record = new ProducerRecord();
record.setTopic("loki");
record.setMessage(IdUtil.getSnowflakeNextIdStr());
ProducerResult result = rocketClient.sendAsync(record).get();

RocketMQ Remoting

依赖注入

@Resource
private RocketRemotingClient rocketRemotingClient;

使用

ProducerRecord record = new ProducerRecord();
record.setTopic("loki");
record.setMessage(IdUtil.getSnowflakeNextIdStr());
ProducerResult result = rocketRemotingClient.sendAsync(record).get();

Kafka

依赖注入

@Resource
private KafkaClient kafkaClient;

使用

ProducerRecord record = new ProducerRecord();
record.setTopic("loki");
record.setMessage(IdUtil.getSnowflakeNextIdStr());
ProducerResult result = kafkaClient.sendAsync(record).get();

Redis

依赖注入

@Resource
private RedisClient redisClient;

使用

ProducerRecord record = new ProducerRecord();
record.setTopic("loki");
record.setMessage(IdUtil.getSnowflakeNextIdStr());
ProducerResult result = redisClient.sendAsync(record).get();

单依赖注入

依赖注入

@Resource
private LokiClient lokiClient;

使用

ProducerRecord record = new ProducerRecord();
record.setTopic("loki");
record.setMessage(IdUtil.getSnowflakeNextIdStr());
ProducerResult result = lokiClient.sendAsync(record).get();