|
|
@ -9,17 +9,29 @@ import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.amqp.core.AmqpTemplate; |
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.PostConstruct; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author 逗 |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
public class SwitchoverProjectUtil { |
|
|
|
@Resource |
|
|
|
private AmqpTemplate amqpTemplate; |
|
|
|
private static SwitchoverProjectUtil util; |
|
|
|
|
|
|
|
@PostConstruct |
|
|
|
public void init(){ |
|
|
|
util = this; |
|
|
|
util.amqpTemplate = this.amqpTemplate; |
|
|
|
} |
|
|
|
|
|
|
|
public static void switchoverProject(Set<String> userIdSet,Long projectId) throws JsonProcessingException { |
|
|
|
AmqpTemplate amqpTemplate = new RabbitTemplate(); |
|
|
|
log.info("切换项目:{}--{}",projectId,userIdSet); |
|
|
|
//设定发送规则
|
|
|
|
MessageRule messageRule = MessageRule.defaultRule(MessageConstant.DomainType.User); |
|
|
@ -34,7 +46,7 @@ public class SwitchoverProjectUtil { |
|
|
|
inMessage.setData(JacksonUtil.beanToJson(recoveryWithStartRecipe)); |
|
|
|
inMessage.setRule(messageRule); |
|
|
|
log.info("发送切换项目信息:{}",inMessage); |
|
|
|
amqpTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME, |
|
|
|
util.amqpTemplate.convertAndSend(RabbitMQConfig.MESSAGE_QUEUE_NAME, |
|
|
|
JacksonUtil.beanToJson(inMessage)); |
|
|
|
} |
|
|
|
} |
|
|
|