package com.iailab.module.data.mq.config;
|
|
import com.iailab.module.data.mq.consumer.ImageMessage;
|
import org.springframework.amqp.core.Binding;
|
import org.springframework.amqp.core.BindingBuilder;
|
import org.springframework.amqp.core.Queue;
|
import org.springframework.amqp.core.TopicExchange;
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
|
/**
|
* @author Houzhongjian
|
* @Description
|
* @createTime 2024年11月06日
|
*/
|
@Configuration
|
public class TopicImageRabbitConfig {
|
//绑定键
|
public final static String routingDahua = ImageMessage.DAHUA_ROUTING_KEY;
|
public final static String routingHikvison = ImageMessage.HIKVISION_ROUTING_KEY;
|
|
@Bean
|
public Queue imageDahuaQueue() {
|
return new Queue(TopicImageRabbitConfig.routingDahua);
|
}
|
|
@Bean
|
public Queue imageHikvisionQueue() {
|
return new Queue(TopicImageRabbitConfig.routingHikvison);
|
}
|
|
@Bean
|
TopicExchange exchange() {
|
return new TopicExchange(ImageMessage.EXCHANGE);
|
}
|
|
// 注意通配符*和#的用法
|
@Bean
|
Binding bindingExchangeMessageDH() {
|
return BindingBuilder.bind(imageDahuaQueue()).to(exchange()).with(routingDahua);
|
}
|
|
@Bean
|
Binding bindingExchangeMessageHK() {
|
return BindingBuilder.bind(imageHikvisionQueue()).to(exchange()).with(routingHikvison);
|
}
|
|
}
|