Skip to content

Commit eefe32f

Browse files
Merge pull request #94 from guoshiqiufeng/release-please--branches--dev--components--standard-version
chore(main): release 1.1.0
2 parents c32d4b8 + 7ec77ae commit eefe32f

File tree

27 files changed

+697
-266
lines changed

27 files changed

+697
-266
lines changed

CHANGELOG.md

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,89 @@
11
# Changelog
22

3-
## [1.0.1](https://github.com/guoshiqiufeng/loki/compare/v1.0.0...v1.0.1) (2024-03-11)
3+
## [1.1.0](https://github.com/guoshiqiufeng/loki/compare/v1.0.1...v1.1.0) (2024-03-19)
4+
5+
6+
### ⭐ New Features
7+
8+
* redis delivery message ([a3d877d](https://github.com/guoshiqiufeng/loki/commit/a3d877d414e7423d3c2d4ee3978a9f48afaaeac3))
49

510

611
### 🐞 Bug Fixes
712

8-
* Dependency optimization ([094514f](https://github.com/guoshiqiufeng/loki/commit/094514fd3e5a37f88f64475490ca35cf5798a277))
13+
* Optimize message sending ([e584156](https://github.com/guoshiqiufeng/loki/commit/e5841569747930f4e1b7ade8abc0ec0d23661db6))
14+
* redis handler consumer ([f3d3739](https://github.com/guoshiqiufeng/loki/commit/f3d37393c3996b485ed1ce43c4cfed661fd74b16))
15+
* zstdJni version ([03f4b75](https://github.com/guoshiqiufeng/loki/commit/03f4b75a5ba6fef21a36a425016d6779ac8288c1))
16+
17+
## [1.0.1](https://github.com/guoshiqiufeng/loki/compare/v1.0.0...v1.0.1) (2024-03-11)
918

19+
### 🐞 Bug Fixes
20+
21+
* Dependency
22+
optimization ([094514f](https://github.com/guoshiqiufeng/loki/commit/094514fd3e5a37f88f64475490ca35cf5798a277))
1023

1124
### 🔨 Dependency Upgrades
1225

1326
* Update hamcrest 2.2 ([545f35f](https://github.com/guoshiqiufeng/loki/commit/545f35fdb7c19c6e90a674f0b7417d3097c4d7d4))
14-
* Update jedisVersion 5.1.2 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
15-
* Update kafkaClients 5.7.0 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
16-
* Update rocketMqClient 5.2.0 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
17-
* Update spring 5.3.32 ([e277eec](https://github.com/guoshiqiufeng/loki/commit/e277eecc58f0cc88d3cef5e91a56faa0f9425111))
27+
* Update jedisVersion
28+
5.1.2 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
29+
* Update kafkaClients
30+
5.7.0 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
31+
* Update rocketMqClient
32+
5.2.0 ([e104c11](https://github.com/guoshiqiufeng/loki/commit/e104c1192bfe736cb15f45dd37da1ddc4394fcda))
33+
* Update spring
34+
5.3.32 ([e277eec](https://github.com/guoshiqiufeng/loki/commit/e277eecc58f0cc88d3cef5e91a56faa0f9425111))
1835

1936
## [1.0.0](https://github.com/guoshiqiufeng/loki/compare/v0.9.0...v1.0.0)
2037

21-
2238
### ⭐ New Features
2339

24-
* LokiClient support listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
25-
40+
* LokiClient support
41+
listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
2642

2743
### 🔨 Dependency Upgrades
2844

29-
* Update gson to 2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
30-
* Update rocketmq-client-java to 5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
31-
* Update zstd-jni to 1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
32-
* Update gradle to 8.6 ([bf9c0e8](https://github.com/guoshiqiufeng/loki/pull/84/commits/bf9c0e8c75d5442424b74b7ade9753f07ce79c8d))
45+
* Update gson to
46+
2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
47+
* Update rocketmq-client-java to
48+
5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
49+
* Update zstd-jni to
50+
1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
51+
* Update gradle to
52+
8.6 ([bf9c0e8](https://github.com/guoshiqiufeng/loki/pull/84/commits/bf9c0e8c75d5442424b74b7ade9753f07ce79c8d))
3353

3454
## [1.0.0-M2](https://github.com/guoshiqiufeng/loki/compare/v0.9.0...v1.0.0-M2)
3555

36-
3756
### ⭐ New Features
3857

39-
* LokiClient support listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
40-
58+
* LokiClient support
59+
listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
4160

4261
### 🔨 Dependency Upgrades
4362

44-
* Update gson to 2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
45-
* Update rocketmq-client-java to 5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
46-
* Update zstd-jni to 1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
47-
* Update gradle to 8.6 ([bf9c0e8](https://github.com/guoshiqiufeng/loki/pull/84/commits/bf9c0e8c75d5442424b74b7ade9753f07ce79c8d))
63+
* Update gson to
64+
2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
65+
* Update rocketmq-client-java to
66+
5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
67+
* Update zstd-jni to
68+
1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
69+
* Update gradle to
70+
8.6 ([bf9c0e8](https://github.com/guoshiqiufeng/loki/pull/84/commits/bf9c0e8c75d5442424b74b7ade9753f07ce79c8d))
4871

4972
## [1.0.0-M1](https://github.com/guoshiqiufeng/loki/compare/v0.9.0...v1.0.0-M1)
5073

51-
5274
### ⭐ New Features
5375

54-
* LokiClient support listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
55-
76+
* LokiClient support
77+
listener ([70975a4](https://github.com/guoshiqiufeng/loki/commit/70975a41a88569399fd14f2de1bc3a6bb7b2d686))
5678

5779
### 🔨 Dependency Upgrades
5880

59-
* Update gson to 2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
60-
* Update rocketmq-client-java to 5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
61-
* Update zstd-jni to 1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
81+
* Update gson to
82+
2.10.1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
83+
* Update rocketmq-client-java to
84+
5.0.6 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
85+
* Update zstd-jni to
86+
1.5.5-1 ([872a873](https://github.com/guoshiqiufeng/loki/commit/872a8739c0cf8caea08de13a92280f8e21370150))
6287

6388
## [0.9.0](https://github.com/guoshiqiufeng/loki/compare/v0.8.1...v0.9.0)
6489

README-zh.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
### 介绍
1111

12-
统一的消息发送、消费框架,简化mq使用。提供统一的消息发送、消费接口,支持多种mq实现,目前支持rocketmq 4.x 以上、Kafka 2.x 以上、Redis 5.X
12+
统一的消息发送、消费框架,简化mq使用。提供统一的消息发送、消费接口,支持多种mq实现,目前支持rocketmq 4.x 以上、Kafka 2.x
13+
以上、Redis 5.X
1314
以上
1415

1516
### 文档
@@ -35,15 +36,18 @@ https://guoshiqiufeng.github.io/loki-doc/
3536
|------------------------------------------------|:-------------:|:-----------------:|-------|-------|
3637
| 【BaseMapper】Send standard messages |||||
3738
| 【BaseMapper】Send async messages |||||
38-
| 【BaseMapper】Send timed/delay messages ||| 🚧 | 🚧 |
39+
| 【BaseMapper】Send timed/delay messages ||| 🚧 | |
3940
| 【LokiClient】Send standard messages |||||
4041
| 【LokiClient】Send async messages |||||
41-
| 【LokiClient】Send timed/delay messages ||| 🚧 | 🚧 |
42+
| 【LokiClient】Send timed/delay messages ||| 🚧 | |
4243
| Producer with transactional messages | 🚧 | 🚧 | 🚧 | 🚧 |
4344
| 【Topic】 consumer with message listener |||||
4445
| 【Topic-Pattern】 consumer with message listener | 🚧 | 🚧 |||
4546

46-
注:Rocketmq-Remoting `Send timed/delay messages` 仅支持 `rocketmq 5.0` 以上版本
47+
注:
48+
49+
- Rocketmq-Remoting `Send timed/delay messages` 仅支持 `rocketmq 5.0` 以上版本
50+
- Redis `Send timed/delay messages` 需要 redis 开启 `notify-keyspace-events Ex` 通知
4751

4852
### 使用
4953

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,18 @@ https://guoshiqiufeng.github.io/loki-doc/en/
3636
|------------------------------------------------|:-------------:|:-----------------:|-------|-------|
3737
| 【BaseMapper】Send standard messages |||||
3838
| 【BaseMapper】Send async messages |||||
39-
| 【BaseMapper】Send timed/delay messages ||| 🚧 | 🚧 |
39+
| 【BaseMapper】Send timed/delay messages ||| 🚧 | |
4040
| 【LokiClient】Send standard messages |||||
4141
| 【LokiClient】Send async messages |||||
42-
| 【LokiClient】Send timed/delay messages ||| 🚧 | 🚧 |
42+
| 【LokiClient】Send timed/delay messages ||| 🚧 | |
4343
| Producer with transactional messages | 🚧 | 🚧 | 🚧 | 🚧 |
4444
| 【Topic】 consumer with message listener |||||
4545
| 【Topic-Pattern】 consumer with message listener | 🚧 | 🚧 |||
4646

47-
Note: Rocketmq-Remoting `Send timed/delay messages` is only supported in `rocketmq 5.0` and above
47+
Note:
48+
49+
- Rocketmq-Remoting `Send timed/delay messages` is only supported in `rocketmq 5.0` and above
50+
- Redis `Send timed/delay messages` requires Redis to enable `notify-keyspace-events Ex` notification.
4851

4952
### Use
5053

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ext {
2727
guavaVersion = "33.0.0-jre",
2828
logbackVersion = "1.4.14",
2929
hamcrestVersion = "2.2",
30+
zstdJniVersion = "1.5.5-1",
3031
]
3132

3233
lib = [
@@ -72,7 +73,7 @@ subprojects {
7273
mavenCentral()
7374
}
7475

75-
def onlyPom = project.name == "loki-bom";
76+
def onlyPom = project.name == "loki-bom"
7677

7778
if (!onlyPom) {
7879
dependencyManagement {
@@ -82,7 +83,7 @@ subprojects {
8283
}
8384
dependencies {
8485
dependency("com.google.code.gson:gson:${gsonVersion}")
85-
// dependency("com.github.luben:zstd-jni:1.5.5-1")
86+
dependency("com.github.luben:zstd-jni:${zstdJniVersion}")
8687
dependency("org.hamcrest:hamcrest:${hamcrestVersion}")
8788
dependency("org.slf4j:slf4j-api:${slf4jVersion}")
8889
dependency("ch.qos.logback:logback-core:${logbackVersion}")

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=1.0.1
2+
APP_VERSION=1.1.0
33
# {x-release-please-end-version}
44
APP_GROUP=io.github.guoshiqiufeng

loki-annotation/src/main/java/io/github/guoshiqiufeng/loki/constant/Constant.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,17 @@
2525
public interface Constant {
2626

2727
/**
28-
* kafaka 标签名
28+
* kafka 标签名
2929
*/
3030
String KAFKA_TAG = "kafka_tag_id";
31+
32+
/**
33+
* redis key 前缀
34+
*/
35+
String REDIS_KEY_PREFIX = "loki:message:";
36+
37+
/**
38+
* redis延时发送列表
39+
*/
40+
String REDIS_DELIVERY_KEY = "loki:delivery";
3141
}

loki-annotation/src/main/java/io/github/guoshiqiufeng/loki/enums/MethodType.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static MethodType getByCode(String code) {
6565
return methodType;
6666
}
6767
}
68-
return null; // 如果没有找到匹配的枚举值,则返回 null
68+
// 如果没有找到匹配的枚举值,则返回 null
69+
return null;
6970
}
7071
}

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

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

1818
import io.github.guoshiqiufeng.loki.support.core.config.LokiProperties;
19-
20-
import javax.annotation.PostConstruct;
19+
import io.github.guoshiqiufeng.loki.support.core.util.StringUtils;
20+
import lombok.extern.slf4j.Slf4j;
2121

2222
/**
2323
* 消息处理事件抽象类
@@ -26,6 +26,7 @@
2626
* @version 1.0
2727
* @since 2023/11/21 13:20
2828
*/
29+
@Slf4j
2930
public abstract class AbstractHandler implements Handler {
3031

3132
/**
@@ -48,7 +49,6 @@ public abstract class AbstractHandler implements Handler {
4849
/**
4950
* 初始化
5051
*/
51-
@PostConstruct
5252
protected void init() {
5353
// 将handler添加到handlerHolder中
5454
handlerHolder.putHandler(type, this);
@@ -64,4 +64,23 @@ public AbstractHandler(LokiProperties properties, HandlerHolder handlerHolder) {
6464
this.properties = properties;
6565
this.handlerHolder = handlerHolder;
6666
}
67+
68+
/**
69+
* 校验参数
70+
*/
71+
protected boolean validateParameters(String topic, String body) {
72+
if (StringUtils.isEmpty(topic)) {
73+
if (log.isErrorEnabled()) {
74+
log.error("{}# send message error: topic is null", this.getClass().getSimpleName());
75+
}
76+
return false;
77+
}
78+
if (StringUtils.isEmpty(body)) {
79+
if (log.isErrorEnabled()) {
80+
log.error("{}# send message error: body is null", this.getClass().getSimpleName());
81+
}
82+
return false;
83+
}
84+
return true;
85+
}
6786
}

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

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import io.github.guoshiqiufeng.loki.support.core.consumer.ConsumerConfig;
2424
import io.github.guoshiqiufeng.loki.support.core.producer.ProducerRecord;
2525
import io.github.guoshiqiufeng.loki.support.core.producer.ProducerResult;
26-
import io.github.guoshiqiufeng.loki.support.core.util.StringUtils;
2726
import io.github.guoshiqiufeng.loki.support.kafka.KafkaClient;
2827
import lombok.extern.slf4j.Slf4j;
2928

@@ -70,22 +69,13 @@ public KafkaHandler(LokiProperties properties, HandlerHolder handlerHolder, Kafk
7069
*/
7170
@Override
7271
public String send(String producerName, String topic, String tag, String body, Long deliveryTimestamp, String... keys) {
73-
if (StringUtils.isEmpty(topic)) {
74-
if (log.isErrorEnabled()) {
75-
log.error("KafkaHandler# send message error: topic is null");
76-
}
77-
return null;
78-
}
79-
if (StringUtils.isEmpty(body)) {
80-
if (log.isErrorEnabled()) {
81-
log.error("KafkaHandler# send message error: body is null");
82-
}
72+
if (!validateParameters(topic, body)) {
8373
return null;
8474
}
8575
// 发送消息
8676
try {
87-
ProducerRecord record = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
88-
return kafkaClient.sendAsync(producerName, record).get().getMsgId();
77+
ProducerRecord producerRecord = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
78+
return kafkaClient.sendAsync(producerName, producerRecord).get().getMsgId();
8979
} catch (Exception e) {
9080
if (log.isErrorEnabled()) {
9181
log.error("KafkaHandler# send message error:{}", e.getMessage());
@@ -108,22 +98,13 @@ public String send(String producerName, String topic, String tag, String body, L
10898
*/
10999
@Override
110100
public CompletableFuture<String> sendAsync(String producerName, String topic, String tag, String body, Long deliveryTimestamp, String... keys) {
111-
if (StringUtils.isEmpty(topic)) {
112-
if (log.isErrorEnabled()) {
113-
log.error("KafkaHandler# send message error: topic is null");
114-
}
115-
return null;
116-
}
117-
if (StringUtils.isEmpty(body)) {
118-
if (log.isErrorEnabled()) {
119-
log.error("KafkaHandler# send message error: body is null");
120-
}
101+
if (!validateParameters(topic, body)) {
121102
return null;
122103
}
123104
// 发送消息
124105
try {
125-
ProducerRecord record = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
126-
return kafkaClient.sendAsync(producerName, record).thenApply(ProducerResult::getMsgId);
106+
ProducerRecord producerRecord = new ProducerRecord(topic, tag, body, deliveryTimestamp, Arrays.asList(keys));
107+
return kafkaClient.sendAsync(producerName, producerRecord).thenApply(ProducerResult::getMsgId);
127108
} catch (Exception e) {
128109
if (log.isErrorEnabled()) {
129110
log.error("KafkaHandler# send message error:{}", e.getMessage());

0 commit comments

Comments
 (0)