refactor(mq): 移除 RocketMQ 消费者和生产者示例代码
- 删除了 yudao-spring-boot-starter-mq 模块中的 Consumer 和 Product 类 - 在 yudao-server 模块中添加了 yudao-spring-boot-starter-mq 依赖 - 更新了 YudaoServerApplication 类,扫描 framework 包 - 在 pom.xml 中添加了 maven-compiler-plugin配置,支持 Java 17
This commit is contained in:
parent
120d592688
commit
7633bc5d5e
9
pom.xml
9
pom.xml
|
|
@ -134,6 +134,15 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.mq.rocketmq.core;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
|
||||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* -
|
|
||||||
*
|
|
||||||
* @author HuangLei
|
|
||||||
* @since 2025-06-18
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RocketMQMessageListener(
|
|
||||||
topic = TopicNameConstants.PAY_REFUND_ORDER,
|
|
||||||
consumerGroup = GroupConstants.PAY_ORDER_REFUND_GROUP)
|
|
||||||
public class Consumer implements RocketMQListener<String> {
|
|
||||||
@Override
|
|
||||||
public void onMessage(String message) {
|
|
||||||
log.info("【消费】- {}", message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
package cn.iocoder.yudao.framework.mq.rocketmq.core;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author HuangLei
|
|
||||||
* @since 2025-06-18
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class Product {
|
|
||||||
|
|
||||||
|
|
||||||
private final RocketMQTemplate rocketMQTemplate;
|
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init(){
|
|
||||||
System.out.println("开始发送消息");
|
|
||||||
rocketMQTemplate.convertAndSend("pay-refund-order", JsonUtils.toJsonString("hello world"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -108,6 +108,12 @@
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.boot</groupId>
|
||||||
|
<artifactId>yudao-spring-boot-starter-mq</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- IoT 物联网相关模块。默认注释,保证编译速度 -->
|
<!-- IoT 物联网相关模块。默认注释,保证编译速度 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
<!-- <groupId>cn.iocoder.boot</groupId>-->
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
||||||
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
||||||
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
* 如果你碰到启动的问题,请认真阅读 https://doc.iocoder.cn/quick-start/ 文章
|
||||||
*
|
* cn.iocoder.yudao.server
|
||||||
* @author 芋道源码
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
|
@SuppressWarnings("SpringComponentScan") // 忽略 IDEA 无法识别 ${yudao.info.base-package}
|
||||||
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module"})
|
@SpringBootApplication(scanBasePackages = {"${yudao.info.base-package}.server", "${yudao.info.base-package}.module",
|
||||||
|
"${yudao.info.base-package}.framework.*"})
|
||||||
public class YudaoServerApplication {
|
public class YudaoServerApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue