feat(REQ-2649): 移除一个重复定义的MQConfig

This commit is contained in:
周敏 2024-08-20 10:17:14 +08:00
parent 2d124a9463
commit c332098ee5

View File

@ -1,50 +0,0 @@
package cn.axzo.nanopart.server.mq;
import cn.axzo.framework.rocketmq.EventProducer;
import cn.axzo.framework.rocketmq.RocketMQEventProducer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
/**
* @Author zr
* @Date 2024/3/21 14:12
* @Description
**/
@Slf4j
@Component
public class RocketMQEventConfiguration {
@Value("${spring.profiles.active}")
private String profileActivity;
private final String serviceName = "nanopart";
private final String topic = "nanopart";
@Bean
public RocketMQTemplate ser(){
return new RocketMQTemplate();
}
@Bean
EventProducer eventProducer(RocketMQTemplate rocketMQTemplate) {
return new RocketMQEventProducer(rocketMQTemplate,
serviceName,
serviceName,
EventProducer.Context.<RocketMQEventProducer.RocketMQMessageMeta>builder()
.meta(RocketMQEventProducer.RocketMQMessageMeta.builder()
.topic(getTopic(topic))
.build())
.build(),
null
);
}
private String getTopic(String topic) {
if (!StringUtils.isEmpty(topic)) {
topic = "topic_"+topic + "_" + profileActivity;
}
return topic;
}
}