-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from guoshiqiufeng/dev
0.7.0
- Loading branch information
Showing
14 changed files
with
294 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,6 @@ bin/ | |
.DS_Store | ||
|
||
### Gradle ### | ||
.gradle | ||
.gradle | ||
|
||
/**/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>io.github.guoshiqiufeng</groupId> | ||
<artifactId>loki-test-root</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
<groupId>io.github.guoshiqiufeng</groupId> | ||
<artifactId>loki-rocketmq-remoting-test</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>loki-rocketmq-remoting-test</name> | ||
<description>loki-rocketmq-remoting-test</description> | ||
<properties> | ||
<java.version>17</java.version> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.github.guoshiqiufeng</groupId> | ||
<artifactId>loki-spring-boot-starter-rocketmq-remoting</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<configuration> | ||
<excludes> | ||
<exclude> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
...-test/src/main/java/io/github/guoshiqiufeng/lokitest/RocketMqRemotingTestApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.guoshiqiufeng.lokitest; | ||
|
||
import io.github.guoshiqiufeng.loki.autoconfigure.register.LokiMapperScan; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@LokiMapperScan | ||
@SpringBootApplication | ||
public class RocketMqRemotingTestApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(RocketMqRemotingTestApplication.class, args); | ||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
...moting-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/TestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package io.github.guoshiqiufeng.lokitest.controller; | ||
|
||
import io.github.guoshiqiufeng.lokitest.entity.TestEntity; | ||
import io.github.guoshiqiufeng.lokitest.mapper.TestMapper; | ||
import jakarta.annotation.Resource; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
@Slf4j | ||
@RestController | ||
public class TestController { | ||
|
||
@Resource | ||
private TestMapper testMapper; | ||
|
||
@GetMapping("send") | ||
public String send() { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("test"); | ||
String messageId = testMapper.send(entity); | ||
log.debug("send messageId:{}", messageId); | ||
return "success"; | ||
} | ||
|
||
@GetMapping("sendAsync") | ||
public String sendAsync() { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("sendAsync"); | ||
testMapper.sendAsync(entity); | ||
return "success"; | ||
} | ||
|
||
@GetMapping("customSend") | ||
public String customSend() { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("test"); | ||
testMapper.customSend(entity); | ||
return "success"; | ||
} | ||
|
||
@GetMapping("deliverySend") | ||
public String deliverySend() { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("test"); | ||
testMapper.deliverySend(entity); | ||
return "success"; | ||
} | ||
|
||
@GetMapping("customSend2") | ||
public String customSend2() { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("test"); | ||
String messageId = testMapper.customSend2(entity); | ||
log.debug("send messageId:{}", messageId); | ||
return "success"; | ||
} | ||
|
||
@GetMapping("customAsyncSend") | ||
public String customAsyncSend() throws ExecutionException, InterruptedException { | ||
TestEntity entity = new TestEntity(); | ||
entity.setId("9521"); | ||
entity.setMessage("test"); | ||
CompletableFuture<String> stringCompletableFuture = testMapper.customAsyncSend(entity); | ||
String messageId = stringCompletableFuture.get(); | ||
log.debug("send messageId:{}", messageId); | ||
return "success"; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ketmq-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/entity/TestEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.github.guoshiqiufeng.lokitest.entity; | ||
|
||
import io.github.guoshiqiufeng.loki.annotation.MessageKey; | ||
import io.github.guoshiqiufeng.loki.annotation.MessageName; | ||
import lombok.Data; | ||
|
||
/** | ||
* @author yanghq | ||
* @version 1.0 | ||
* @since 2023/11/24 10:37 | ||
*/ | ||
@Data | ||
@MessageName(topic = "loki", tag = "create") | ||
public class TestEntity { | ||
|
||
@MessageKey | ||
private String id; | ||
|
||
private String message; | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
...est/src/main/java/io/github/guoshiqiufeng/lokitest/listener/TestDelayMessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.guoshiqiufeng.lokitest.listener; | ||
|
||
import io.github.guoshiqiufeng.loki.Listener; | ||
import io.github.guoshiqiufeng.loki.MessageContent; | ||
import io.github.guoshiqiufeng.loki.annotation.MessageListener; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@MessageListener(topic = "lokiDelay") | ||
@Component | ||
public class TestDelayMessageListener implements Listener<String> { | ||
@Override | ||
public void onMessage(MessageContent<String> entity) { | ||
log.info("entity:{}", entity); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...q-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/listener/TestListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.github.guoshiqiufeng.lokitest.listener; | ||
|
||
import io.github.guoshiqiufeng.loki.Listener; | ||
import io.github.guoshiqiufeng.loki.MessageContent; | ||
import io.github.guoshiqiufeng.lokitest.entity.TestEntity; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
public class TestListener implements Listener<TestEntity> { | ||
@Override | ||
public void onMessage(MessageContent<TestEntity> entity) { | ||
log.info("entity:{}", entity); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ing-test/src/main/java/io/github/guoshiqiufeng/lokitest/listener/TestMessageListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.guoshiqiufeng.lokitest.listener; | ||
|
||
import io.github.guoshiqiufeng.loki.Listener; | ||
import io.github.guoshiqiufeng.loki.MessageContent; | ||
import io.github.guoshiqiufeng.loki.annotation.MessageListener; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@MessageListener(topic = "loki") | ||
@Component | ||
public class TestMessageListener implements Listener<String> { | ||
@Override | ||
public void onMessage(MessageContent<String> entity) { | ||
log.info("entity:{}", entity); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...ketmq-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/mapper/TestMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.github.guoshiqiufeng.lokitest.mapper; | ||
|
||
import io.github.guoshiqiufeng.loki.annotation.SendMessage; | ||
import io.github.guoshiqiufeng.loki.core.mapper.BaseMapper; | ||
import io.github.guoshiqiufeng.lokitest.entity.TestEntity; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* @author yanghq | ||
* @version 1.0 | ||
* @since 2023/11/24 10:38 | ||
*/ | ||
public interface TestMapper extends BaseMapper<TestEntity> { | ||
|
||
@SendMessage(topic = "loki", tag = "custom", message = "#entity.message", messageKey = "#entity.id") | ||
void customSend(TestEntity entity); | ||
|
||
@SendMessage(topic = "loki", tag = "custom", message = "#entity.message", messageKey = "#entity.id") | ||
String customSend2(TestEntity entity); | ||
|
||
@SendMessage(topic = "loki", tag = "custom", async = true, message = "#entity.message", messageKey = "#entity.id") | ||
CompletableFuture<String> customAsyncSend(TestEntity entity); | ||
|
||
@SendMessage(topic = "lokiDelay", tag = "custom", message = "#entity.message", deliveryTimestamp = 23 * 1000,messageKey = "#entity.id") | ||
void deliverySend(TestEntity entity); | ||
} |
18 changes: 18 additions & 0 deletions
18
loki-rocketmq-remoting-test/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
server: | ||
port: 8889 | ||
logging: | ||
level: | ||
io.github.guoshiqiufeng.loki: debug | ||
io.github.guoshiqiufeng.lokitest: debug | ||
|
||
rocketmq: | ||
producer: | ||
group: loki-group | ||
|
||
loki: | ||
global-config: | ||
mq-config: | ||
mq-type: rocket_mq_remoting | ||
address: 127.0.0.1:9876 | ||
connect-timeout: 300 | ||
max-attempts: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters