Skip to content

Commit 9f9f18b

Browse files
chore(main): release 0.9.0 (#77)
* 0.9.0-SNAPSHOT * feat: Send Message Interceptor * feat: Send Listener Interceptor * fix: LokiClient for RocketRemotingClient * fix: redis auth is false,set password * Interceptor result empty --------- Co-authored-by: 過世秋風 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e52855f commit 9f9f18b

File tree

53 files changed

+1435
-520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1435
-520
lines changed

CHANGELOG.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,65 @@
11
# Changelog
22

3-
## [0.8.0](https://github.com/guoshiqiufeng/loki/compare/v0.7.0...v0.8.0)
3+
## [0.9.0](https://github.com/guoshiqiufeng/loki/compare/v0.8.1...v0.9.0) (2024-02-02)
44

55

66
### ⭐ New Features
77

8-
* Add LokiClient support sending messages ([f685a9a](https://github.com/guoshiqiufeng/loki/commit/f685a9a705c6a7f072fed490e572eb3d79eab4f1))
8+
* Send Listener Interceptor ([fef9a46](https://github.com/guoshiqiufeng/loki/commit/fef9a46563447f0e80c1b985508dff92a7f992c1))
9+
* Send Message Interceptor ([33cf09e](https://github.com/guoshiqiufeng/loki/commit/33cf09ea58e4d3ad2561b92bb0eff16365f7cc01))
10+
11+
12+
### 🐞 Bug Fixes
13+
14+
* LokiClient for RocketRemotingClient ([e1519fd](https://github.com/guoshiqiufeng/loki/commit/e1519fd46f24cec2291beb7b87ce2f6d5300131e))
15+
* redis auth is false,set password ([35d5f0d](https://github.com/guoshiqiufeng/loki/commit/35d5f0d5c03f5a469f4c66d16091b27f7d7947d6))
916

17+
## [0.8.1](https://github.com/guoshiqiufeng/loki/compare/v0.8.0...v0.8.1)
1018

1119
### 🐞 Bug Fixes
1220

13-
* bom only pom to maven ([90e3a8b](https://github.com/guoshiqiufeng/loki/commit/90e3a8b2d62255cafd245e5dafc02db9bff29c53))
14-
* spring-boot-starter dependencies ([b9c2dfc](https://github.com/guoshiqiufeng/loki/commit/b9c2dfcc905d19ef9c8ce99dc3d8f8820fafb506))
21+
- fix starter dependency(https://github.com/guoshiqiufeng/loki/commit/e52855f09bfdc92720dbb2b5b070117c1bd37beb)
22+
23+
## [0.8.0](https://github.com/guoshiqiufeng/loki/compare/v0.7.0...v0.8.0)
1524

25+
### ⭐ New Features
26+
27+
* Add LokiClient support sending
28+
messages ([f685a9a](https://github.com/guoshiqiufeng/loki/commit/f685a9a705c6a7f072fed490e572eb3d79eab4f1))
29+
30+
### 🐞 Bug Fixes
31+
32+
* bom only pom to
33+
maven ([90e3a8b](https://github.com/guoshiqiufeng/loki/commit/90e3a8b2d62255cafd245e5dafc02db9bff29c53))
34+
* spring-boot-starter
35+
dependencies ([b9c2dfc](https://github.com/guoshiqiufeng/loki/commit/b9c2dfcc905d19ef9c8ce99dc3d8f8820fafb506))
1636

1737
### 🔨 Dependency Upgrades
1838

19-
* Update guava to 33.0.0-jre ([ebc15ec](https://github.com/guoshiqiufeng/loki/commit/ebc15ece6a548a251e4cb1e22219d46cfc606636))
20-
* Update okhttp to 4.12.0 ([9b12af1](https://github.com/guoshiqiufeng/loki/commit/9b12af1fec0d06516eb85e4e2c5deb8185dd2e7c))
21-
* Update opentelemetry to 1.31.0 ([9b12af1](https://github.com/guoshiqiufeng/loki/commit/9b12af1fec0d06516eb85e4e2c5deb8185dd2e7c))
39+
* Update guava to
40+
33.0.0-jre ([ebc15ec](https://github.com/guoshiqiufeng/loki/commit/ebc15ece6a548a251e4cb1e22219d46cfc606636))
41+
* Update okhttp to
42+
4.12.0 ([9b12af1](https://github.com/guoshiqiufeng/loki/commit/9b12af1fec0d06516eb85e4e2c5deb8185dd2e7c))
43+
* Update opentelemetry to
44+
1.31.0 ([9b12af1](https://github.com/guoshiqiufeng/loki/commit/9b12af1fec0d06516eb85e4e2c5deb8185dd2e7c))
2245

2346
## [0.7.0](https://github.com/guoshiqiufeng/loki/compare/v0.6.1...v0.7.0)
2447

25-
2648
### ⭐ New Features
2749

2850
* rocketmq-gRPC ([ecda4d7](https://github.com/guoshiqiufeng/loki/commit/ecda4d7106ddba2c91e13ad042593ed91a59ead3))
2951
* rocketmq-remoting ([1af7499](https://github.com/guoshiqiufeng/loki/commit/1af74997aa03a672f6fc9dba32e6c7277cd830e2))
3052
* rocketmq-remoting ([40e0138](https://github.com/guoshiqiufeng/loki/commit/40e01381b1a3224d0cd49c43acf475e329bc8abe))
3153

32-
3354
### 🐞 Bug Fixes
3455

35-
* bom add support dependency ([8ba36c3](https://github.com/guoshiqiufeng/loki/commit/8ba36c3101fa95696d11dfad35e55f9bda52ad6f))
36-
56+
* bom add support
57+
dependency ([8ba36c3](https://github.com/guoshiqiufeng/loki/commit/8ba36c3101fa95696d11dfad35e55f9bda52ad6f))
3758

3859
### 🔨 Dependency Upgrades
3960

40-
* Update hutool to 5.8.25 ([30f72db](https://github.com/guoshiqiufeng/loki/commit/30f72db9a48250518d7990f8449976ae19227651))
61+
* Update hutool to
62+
5.8.25 ([30f72db](https://github.com/guoshiqiufeng/loki/commit/30f72db9a48250518d7990f8449976ae19227651))
4163

4264
## [0.6.1](https://github.com/guoshiqiufeng/loki/compare/v0.6.0...v0.6.1)
4365

README-zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ https://guoshiqiufeng.github.io/loki-doc/
3434
|------------------------------------------------|:-------------:|:-----------------:|-------|-------|
3535
| 【BaseMapper】Send standard messages |||||
3636
| 【BaseMapper】Send async messages |||||
37-
| 【BaseMapper】Send timed/delay messages ||| 🚧 | 🚧 |
37+
| 【BaseMapper】Send timed/delay messages || | 🚧 | 🚧 |
3838
| 【LokiClient】Send standard messages |||||
3939
| 【LokiClient】Send async messages |||||
40-
| 【LokiClient】Send timed/delay messages ||| 🚧 | 🚧 |
40+
| 【LokiClient】Send timed/delay messages || | 🚧 | 🚧 |
4141
| Producer with transactional messages | 🚧 | 🚧 | 🚧 | 🚧 |
4242
| 【Topic】 consumer with message listener |||||
4343
| 【Topic-Pattern】 consumer with message listener | 🚧 | 🚧 |||

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ https://guoshiqiufeng.github.io/loki-doc/en/
3535
|------------------------------------------------|:-------------:|:-----------------:|-------|-------|
3636
| 【BaseMapper】Send standard messages |||||
3737
| 【BaseMapper】Send async messages |||||
38-
| 【BaseMapper】Send timed/delay messages ||| 🚧 | 🚧 |
38+
| 【BaseMapper】Send timed/delay messages || | 🚧 | 🚧 |
3939
| 【LokiClient】Send standard messages |||||
4040
| 【LokiClient】Send async messages |||||
41-
| 【LokiClient】Send timed/delay messages ||| 🚧 | 🚧 |
41+
| 【LokiClient】Send timed/delay messages || | 🚧 | 🚧 |
4242
| Producer with transactional messages | 🚧 | 🚧 | 🚧 | 🚧 |
4343
| 【Topic】 consumer with message listener |||||
4444
| 【Topic-Pattern】 consumer with message listener | 🚧 | 🚧 |||

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ subprojects {
6464
mavenCentral()
6565
}
6666

67-
if(project.name == "loki-spring-boot-starter" || project.name == "loki-spring-boot-starter-rocketmq-remoting" || project.name == "loki-support-rocketmq-remoting") {
67+
if (project.name == "loki-spring-boot-starter" || project.name == "loki-spring-boot-starter-rocketmq-remoting" || project.name == "loki-support-rocketmq-remoting") {
6868
dependencies {
6969
implementation platform("io.opentelemetry:opentelemetry-bom:${opentelemetryVersion}")
7070
implementation platform("com.squareup.okhttp3:okhttp-bom:${okhttpVersion}")
@@ -180,14 +180,14 @@ subprojects {
180180
}
181181
publications {
182182
mavenJava(MavenPublication) {
183-
if(!onlyPom) {
183+
if (!onlyPom) {
184184
from components.java
185185
artifact sourcesJar
186186
artifact javadocJar
187187
}
188188
pom {
189189
name = 'loki'
190-
if(onlyPom) {
190+
if (onlyPom) {
191191
packaging 'pom'
192192
} else {
193193
packaging 'jar'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# {x-release-please-start-version}
2-
APP_VERSION=0.8.1
2+
APP_VERSION=0.9.0
33
# {x-release-please-end-version}
44
APP_GROUP=io.github.guoshiqiufeng

loki-core/src/main/java/io/github/guoshiqiufeng/loki/core/config/BaseCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
*/
1616
package io.github.guoshiqiufeng.loki.core.config;
1717

18-
import io.github.guoshiqiufeng.loki.support.core.exception.LokiException;
1918
import io.github.guoshiqiufeng.loki.core.handler.HandlerHolder;
2019
import io.github.guoshiqiufeng.loki.core.mapper.BaseMapper;
2120
import io.github.guoshiqiufeng.loki.core.mapper.BaseMapperImpl;
2221
import io.github.guoshiqiufeng.loki.support.core.config.LokiProperties;
22+
import io.github.guoshiqiufeng.loki.support.core.exception.LokiException;
2323
import lombok.experimental.UtilityClass;
2424

2525
import java.util.Map;

loki-core/src/main/java/io/github/guoshiqiufeng/loki/core/handler/impl/KafkaHandler.java

Lines changed: 20 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,22 @@
1616
package io.github.guoshiqiufeng.loki.core.handler.impl;
1717

1818
import io.github.guoshiqiufeng.loki.MessageContent;
19-
import io.github.guoshiqiufeng.loki.constant.Constant;
2019
import io.github.guoshiqiufeng.loki.core.config.ConsumerConfig;
2120
import io.github.guoshiqiufeng.loki.core.handler.AbstractHandler;
2221
import io.github.guoshiqiufeng.loki.core.handler.HandlerHolder;
23-
import io.github.guoshiqiufeng.loki.support.core.util.StringUtils;
2422
import io.github.guoshiqiufeng.loki.core.toolkit.ThreadPoolUtils;
2523
import io.github.guoshiqiufeng.loki.enums.MqType;
2624
import io.github.guoshiqiufeng.loki.support.core.config.LokiProperties;
25+
import io.github.guoshiqiufeng.loki.support.core.producer.ProducerRecord;
26+
import io.github.guoshiqiufeng.loki.support.core.producer.ProducerResult;
27+
import io.github.guoshiqiufeng.loki.support.core.util.StringUtils;
2728
import io.github.guoshiqiufeng.loki.support.kafka.KafkaClient;
2829
import io.github.guoshiqiufeng.loki.support.kafka.utils.KafkaConsumeUtils;
2930
import lombok.extern.slf4j.Slf4j;
30-
import org.apache.kafka.clients.consumer.ConsumerRecord;
3131
import org.apache.kafka.clients.consumer.KafkaConsumer;
32-
import org.apache.kafka.clients.producer.ProducerRecord;
33-
import org.apache.kafka.clients.producer.RecordMetadata;
34-
import org.apache.kafka.common.header.Header;
35-
import org.apache.kafka.common.header.internals.RecordHeader;
3632

37-
import java.nio.charset.StandardCharsets;
38-
import java.util.ArrayList;
39-
import java.util.Collections;
40-
import java.util.List;
33+
import java.util.Arrays;
4134
import java.util.concurrent.CompletableFuture;
42-
import java.util.concurrent.ExecutionException;
4335
import java.util.concurrent.ExecutorService;
4436
import java.util.function.Function;
4537

@@ -96,20 +88,8 @@ public String send(String producerName, String topic, String tag, String body, L
9688
}
9789
// 发送消息
9890
try {
99-
List<Header> headers = new ArrayList<>();
100-
if (StringUtils.isNotEmpty(tag)) {
101-
headers.add(new RecordHeader(Constant.KAFKA_TAG, tag.getBytes(StandardCharsets.UTF_8)));
102-
}
103-
Long timestamp = null;
104-
if (deliveryTimestamp != null && deliveryTimestamp != 0) {
105-
timestamp = System.currentTimeMillis() + deliveryTimestamp;
106-
}
107-
String key = null;
108-
if (keys != null && keys.length > 0) {
109-
key = keys[0];
110-
}
111-
ProducerRecord<String, String> record = new ProducerRecord<>(topic, null, timestamp, key, body, headers);
112-
return getMessageId(kafkaClient.send(producerName, record).get());
91+
ProducerRecord record = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
92+
return kafkaClient.sendAsync(producerName, record).get().getMsgId();
11393
} catch (Exception e) {
11494
if (log.isErrorEnabled()) {
11595
log.error("KafkaHandler# send message error:{}", e.getMessage());
@@ -146,27 +126,8 @@ public CompletableFuture<String> sendAsync(String producerName, String topic, St
146126
}
147127
// 发送消息
148128
try {
149-
List<Header> headers = new ArrayList<>();
150-
if (StringUtils.isNotEmpty(tag)) {
151-
headers.add(new RecordHeader(Constant.KAFKA_TAG, tag.getBytes(StandardCharsets.UTF_8)));
152-
}
153-
Long timestamp = null;
154-
if (deliveryTimestamp != null && deliveryTimestamp != 0) {
155-
timestamp = System.currentTimeMillis() + deliveryTimestamp;
156-
}
157-
String key = null;
158-
if (keys != null && keys.length > 0) {
159-
key = keys[0];
160-
}
161-
ProducerRecord<String, String> record = new ProducerRecord<>(topic, null, timestamp, key, body, headers);
162-
return CompletableFuture.supplyAsync(() -> {
163-
try {
164-
return kafkaClient.send(producerName, record).get();
165-
} catch (InterruptedException | ExecutionException e) {
166-
throw new RuntimeException(e);
167-
}
168-
})
169-
.thenApplyAsync(this::getMessageId);
129+
ProducerRecord record = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
130+
return kafkaClient.sendAsync(producerName, record).thenApply(ProducerResult::getMsgId);
170131
} catch (Exception e) {
171132
if (log.isErrorEnabled()) {
172133
log.error("KafkaHandler# send message error:{}", e.getMessage());
@@ -205,25 +166,25 @@ public void pushMessageListener(ConsumerConfig consumerConfig, Function<MessageC
205166
consumer,
206167
topicPattern, finalTag,
207168
record -> function.apply(new MessageContent<String>()
208-
.setMessageId(getMessageId(record))
169+
.setMessageId(record.getMessageId())
209170
// .setMessageGroup(messageGroup)
210-
.setTopic(record.topic())
211-
.setTag(record.tag())
212-
.setKeys(Collections.singletonList(record.key()))
213-
.setBody(record.value())
214-
.setBodyMessage(record.value())));
171+
.setTopic(record.getTopic())
172+
.setTag(record.getTag())
173+
.setKeys(record.getKeys())
174+
.setBody(record.getBodyMessage())
175+
.setBodyMessage(record.getBodyMessage())));
215176
} else {
216177
KafkaConsumeUtils.consumeMessage(
217178
consumer,
218179
topic, finalTag,
219180
record -> function.apply(new MessageContent<String>()
220-
.setMessageId(getMessageId(record))
181+
.setMessageId(record.getMessageId())
221182
// .setMessageGroup(messageGroup)
222-
.setTopic(record.topic())
223-
.setTag(record.tag())
224-
.setKeys(Collections.singletonList(record.key()))
225-
.setBody(record.value())
226-
.setBodyMessage(record.value())));
183+
.setTopic(record.getTopic())
184+
.setTag(record.getTag())
185+
.setKeys(record.getKeys())
186+
.setBody(record.getBodyMessage())
187+
.setBodyMessage(record.getBodyMessage())));
227188
}
228189

229190
}, executorService).exceptionally(throwable -> {
@@ -241,19 +202,4 @@ record -> function.apply(new MessageContent<String>()
241202
}
242203
}
243204

244-
/**
245-
* 获取消息id<br>
246-
* 使用partition和offset拼接
247-
*
248-
* @param recordMetadata recordMetadata
249-
* @return 消息id
250-
*/
251-
private String getMessageId(RecordMetadata recordMetadata) {
252-
return recordMetadata.partition() + "_" + recordMetadata.offset();
253-
}
254-
255-
private String getMessageId(ConsumerRecord<String, String> recordMetadata) {
256-
return recordMetadata.partition() + "_" + recordMetadata.offset();
257-
}
258-
259205
}

0 commit comments

Comments
 (0)