Working with LokiClient
Detailed usage examples can be found in loki-test in
ClientController.java
Request Parameters
Parameter name | Required | Remarks |
---|---|---|
topic | Y | topic |
tag | N | tag |
message | Y | Message Content |
deliveryTimestamp | N | delivery timestamp |
keys | N | key |
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();