提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.framework.tenant.core.mq.rabbitmq; |
H |
2 |
|
|
3 |
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
4 |
import org.springframework.beans.BeansException; |
|
5 |
import org.springframework.beans.factory.config.BeanPostProcessor; |
|
6 |
|
|
7 |
/** |
|
8 |
* 多租户的 RabbitMQ 初始化器 |
|
9 |
* |
|
10 |
* @author iailab |
|
11 |
*/ |
|
12 |
public class TenantRabbitMQInitializer implements BeanPostProcessor { |
|
13 |
|
|
14 |
@Override |
|
15 |
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { |
|
16 |
if (bean instanceof RabbitTemplate) { |
|
17 |
RabbitTemplate rabbitTemplate = (RabbitTemplate) bean; |
|
18 |
rabbitTemplate.addBeforePublishPostProcessors(new TenantRabbitMQMessagePostProcessor()); |
|
19 |
} |
|
20 |
return bean; |
|
21 |
} |
|
22 |
|
|
23 |
} |