Working with LokiClient

Detailed usage examples can be found in loki-testopen in new window in ClientController.java

Request Parameters

Parameter nameRequiredRemarks
topicYtopic
tagNtag
messageYMessage Content
deliveryTimestampNdelivery timestamp
keysNkey

Full dependency injection

RocketMQ

Dependency Injection

@Resource
private RocketClient rocketClient;

Use

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

RocketMQ Remoting

Dependency Injection

@Resource
private RocketRemotingClient rocketRemotingClient;

Use

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

Kafka

Dependency Injection

@Resource
private KafkaClient kafkaClient;

Use

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

Redis

Dependency Injection

@Resource
private RedisClient redisClient;

Use

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

Single dependency injection

Dependency Injection

@Resource
private LokiClient lokiClient;

Use

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