Skip to content

Commit

Permalink
Merge pull request #1 from guoshiqiufeng/dev
Browse files Browse the repository at this point in the history
0.7.0
  • Loading branch information
guoshiqiufeng authored Jan 23, 2024
2 parents 8745907 + 440013c commit f4de7a6
Show file tree
Hide file tree
Showing 14 changed files with 294 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ bin/
.DS_Store

### Gradle ###
.gradle
.gradle

/**/target/
57 changes: 57 additions & 0 deletions loki-rocketmq-remoting-test/pom.xml
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>
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);
}

}
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";
}
}
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;
}

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);
}
}
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);
}
}
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);
}
}
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 loki-rocketmq-remoting-test/src/main/resources/application.yml
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package io.github.guoshiqiufeng.lokitest.controller;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import io.github.guoshiqiufeng.lokitest.entity.TestEntity;
import io.github.guoshiqiufeng.lokitest.mapper.TestMapper;
import jakarta.annotation.Resource;
Expand Down Expand Up @@ -45,6 +53,15 @@ public String customSend() {
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();
Expand All @@ -65,4 +82,4 @@ public String customAsyncSend() throws ExecutionException, InterruptedException
log.debug("send messageId:{}", messageId);
return "success";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import org.springframework.stereotype.Component;

@Slf4j
@MessageListener(topic = "loki")
@MessageListener(topic = "lokiDelay")
@Component
public class TestMessageListener implements Listener<String> {
@Override
public void onMessage(MessageContent<String> entity) {
log.info("entity:{}", entity);
log.info("TestMessageListener entity:{}", entity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public interface TestMapper extends BaseMapper<TestEntity> {
@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 = 20 * 1000,messageKey = "#entity.id")
void deliverySend(TestEntity entity);

}
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<properties>
<java.version>17</java.version>
<loki.version>0.6.1</loki.version>
<loki.version>0.7.0</loki.version>
</properties>

<dependencyManagement>
Expand All @@ -36,6 +36,7 @@

<modules>
<module>loki-simple-test</module>
<module>loki-rocketmq-remoting-test</module>
<module>loki-rocketmq-test</module>
<module>loki-kafka-test</module>
<module>loki-redis-test</module>
Expand Down

0 comments on commit f4de7a6

Please sign in to comment.