这是我的配置类
public class MQConfig {
/**
* //direct、topic、fanout。direct直连模式,指定某个队列接收
* topic通配符模式,同上 但是支持通配符
* fanout广播模式。所有队列都能接收到消息
* @return
*/
@Bean(MQ.EXCHANGE_COURSE_ONLINE)
public Exchange EXCHANGE_NAME_TOPIC(){
return ExchangeBuilder.topicExchange(MQ.EXCHANGE_COURSE_ONLINE).durable(true).build();//durable(true)开启持久化
}
/**
* 创建队列
* @return
*/
@Bean(MQ.QUEUE_COURSE_ONLINE_MAIL)
public Queue QUEUE_NAME_MAIL(){
return QueueBuilder.durable(MQ.QUEUE_COURSE_ONLINE_MAIL).build();
}
@Bean(MQ.QUEUE_COURSE_ONLINE_SMS)
public Queue QUEUE_NAME_SMS(){
return QueueBuilder.durable(MQ.QUEUE_COURSE_ONLINE_SMS).build();
}
/**
* 绑定交换机到队列
* @param emailQueue
* @param exchange
* @return
*/
@Bean
public Binding emailQueueBinding(@Qualifier(MQ.QUEUE_COURSE_ONLINE_MAIL) Queue emailQueue, Exchange exchange){
return BindingBuilder.bind(emailQueue).to(exchange).with("mail.#").noargs();
}
@Bean
public Binding smsQueueBinding(@Qualifier(MQ.QUEUE_COURSE_ONLINE_SMS) Queue smsQueue, Exchange exchange){
return BindingBuilder.bind(smsQueue).to(exchange).with("sms.#").noargs();
}
}
生产者是这样发送消息的
rabbitTemplate.convertAndSend(MQ.EXCHANGE_COURSE_ONLINE,"sms.course.online", courses);
rabbitTemplate.convertAndSend(MQ.EXCHANGE_COURSE_ONLINE,"mail.course.online", courses);
那么我应该怎么开启生产者的confirm确认机制呢