| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package com.persagy.person.mq;
- import org.springframework.amqp.rabbit.core.RabbitTemplate;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import com.alibaba.fastjson.JSON;
- import com.persagy.person.config.ApplicationProperties;
- import com.persagy.person.pojo.dto.SaasAccount;
- import com.persagy.person.pojo.dto.SaasGroup;
- import lombok.extern.slf4j.Slf4j;
- /**
- * @version
- * @description
- * @company persagy
- * @author zhangqiankun
- * @since 2021年3月2日: 下午2:24:08
- */
- @Slf4j
- @Component
- public class CommonTopicProducer {
-
- @Autowired
- private RabbitTemplate rabbitTemplate;
-
- @Autowired
- private ApplicationProperties properties;
-
- /**
- * 创建集团信息时,投递至mq
- *
- * @param type 类型 create-创建,update-更新
- */
- public void sendGroupInfo(SaasGroup saasGroup, String type) {
- if (properties.isRaabitmqEnable()) {
- saasGroup.setType(type);
- String message = JSON.toJSONString(saasGroup);
- log.info("send rabbitmq group message to " + properties.getCommonExchange() + " : " + message);
- this.rabbitTemplate.convertAndSend(properties.getCommonExchange(), properties.getGroupRouteKey(), message);
- }
- }
-
- /**
- * 创建集团管理员账号信息时,投递至mq
- *
- * @param type 类型 create-创建,update-更新
- */
- public void sendAccountInfo(SaasAccount saasAccount, String type) {
- if (properties.isRaabitmqEnable()) {
- saasAccount.setType(type);
- saasAccount.setPassword(null);
- String message = JSON.toJSONString(saasAccount);
- log.info("send rabbitmq account message to " + properties.getCommonExchange() + " : " + message);
- this.rabbitTemplate.convertAndSend(properties.getCommonExchange(), properties.getAccountRouteKey(), message);
- }
- }
- }
|