opt: 任务发送消费者topic定义

This commit is contained in:
2026-07-23 16:48:05 +08:00
parent 65fb53fc00
commit 6f566b7a69
11 changed files with 94 additions and 87 deletions

View File

@@ -6,19 +6,21 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import java.util.UUID;
/**
* 任务事件 MQ 生产者
* <p>
* Topic: TASK_EVENT_TOPIC
* Topic 从 YAML 配置 rocketmq.consumer.task.topic 读取
* Tag: ownerService (LMS / WMS)
*/
@Slf4j
@Component
public class TaskEventProducer {
private static final String TOPIC = "TASK_EVENT_TOPIC";
@Value("${rocketmq.consumer.task.topic}")
private String topic;
@Resource
private RocketMQTemplate rocketMQTemplate;
@@ -34,7 +36,7 @@ public class TaskEventProducer {
message.setEventId(UUID.randomUUID().toString());
}
String destination = TOPIC + "_" + message.getOwnerService();
String destination = message.getOwnerService() + "_" + topic;
try {
rocketMQTemplate.syncSend(destination, message);
log.info("MQ 发送成功, destination={}, taskId={}, eventType={}",

View File

@@ -78,9 +78,12 @@ spring:
# rocketmq 配置项,对应 RocketMQProperties 配置类
rocketmq:
name-server: 127.0.0.1:9876 # RocketMQ Namesrv
name-server: 192.168.81.193:9876 # RocketMQ Namesrv
producer:
group: ${spring.application.name}_TASK_DEV_PRODUCER # 生产者分组
group: task-producer-dev-group # 生产者分组
consumer:
task:
topic: task-status-change-dev-topic
spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类