parent
7b06715bff
commit
f1496b5084
@ -0,0 +1,22 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-cloud-test</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<description>消息队列测试模块</description>
|
||||
<artifactId>jeecg-cloud-test-rocketmq</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<!-- rocketmq消息队列-->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-starter-rocketmq</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
package org.jeecg.modules.test.rocketmq.constant;
|
||||
|
||||
/**
|
||||
* 微服务单元测试常量定义
|
||||
* @author: zyf
|
||||
* @date: 2022/04/21
|
||||
*/
|
||||
public interface CloudConstant {
|
||||
|
||||
|
||||
/**
|
||||
* MQ测试队列名字
|
||||
*/
|
||||
public final static String MQ_JEECG_PLACE_ORDER = "jeecg_place_order";
|
||||
public final static String MQ_JEECG_PLACE_ORDER_TIME = "jeecg_place_order_time";
|
||||
|
||||
/**
|
||||
* MQ测试消息总线
|
||||
*/
|
||||
public final static String MQ_DEMO_BUS_EVENT = "demoBusEvent";
|
||||
|
||||
/**
|
||||
* 分布式锁lock key
|
||||
*/
|
||||
public final static String REDISSON_DEMO_LOCK_KEY1 = "demoLockKey1";
|
||||
public final static String REDISSON_DEMO_LOCK_KEY2 = "demoLockKey2";
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package org.jeecg.modules.test.rocketmq.event;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.boot.starter.rabbitmq.event.EventObj;
|
||||
import org.jeecg.boot.starter.rabbitmq.event.JeecgBusEventHandler;
|
||||
import org.jeecg.common.base.BaseMap;
|
||||
import org.jeecg.modules.test.rocketmq.constant.CloudConstant;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 消息处理器【发布订阅】
|
||||
* @author: zyf
|
||||
* @date: 2022/04/21
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(CloudConstant.MQ_DEMO_BUS_EVENT)
|
||||
public class DemoBusEvent implements JeecgBusEventHandler {
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(EventObj obj) {
|
||||
if (ObjectUtil.isNotEmpty(obj)) {
|
||||
BaseMap baseMap = obj.getBaseMap();
|
||||
String orderId = baseMap.get("orderId");
|
||||
log.info("业务处理----订单ID:" + orderId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue