package com.iailab.framework.tenant.core.mq.rabbitmq;
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.beans.BeansException;
|
import org.springframework.beans.factory.config.BeanPostProcessor;
|
|
/**
|
* 多租户的 RabbitMQ 初始化器
|
*
|
* @author iailab
|
*/
|
public class TenantRabbitMQInitializer implements BeanPostProcessor {
|
|
@Override
|
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
if (bean instanceof RabbitTemplate) {
|
RabbitTemplate rabbitTemplate = (RabbitTemplate) bean;
|
rabbitTemplate.addBeforePublishPostProcessors(new TenantRabbitMQMessagePostProcessor());
|
}
|
return bean;
|
}
|
|
}
|