package boot.spring.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import boot.spring.po.Mail;
import boot.spring.po.TopicMail;
import boot.spring.service.impl.ProducerImpl;
import boot.spring.service.impl.PublisherImpl;
@Controller
public class RabbitMQController {
@Autowired
ProducerImpl producer;
@Autowired
PublisherImpl publisher;
@RequestMapping(value="/produce",produces = {"application/json;charset=UTF-8"})
@ResponseBody
public void produce(@ModelAttribute("mail")Mail mail) throws Exception{
producer.sendMail("myqueue",mail);
}
@RequestMapping(value="/topic",produces = {"application/json;charset=UTF-8"})
@ResponseBody
public void topic(@ModelAttribute("mail")Mail mail) throws Exception{
publisher.publishMail(mail);
}
@RequestMapping(value="/direct",produces = {"application/json;charset=UTF-8"})
@ResponseBody
public void direct(@ModelAttribute("mail")TopicMail mail){
Mail m=new Mail(mail.getMailId(),mail.getCountry(),mail.getWeight());
publisher.senddirectMail(m, mail.getRoutingkey());
}
@RequestMapping(value="/mytopic",produces = {"application/json;charset=UTF-8"})
@ResponseBody
public void topic(@ModelAttribute("mail")TopicMail mail){
Mail m=new Mail(mail.getMailId(),mail.getCountry(),mail.getWeight());
publisher.sendtopicMail(m, mail.getRoutingkey());
}
@RequestMapping("demo")
public String demo(){
return "demo";
}
}
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
m0_72731342
- 粉丝: 4
- 资源: 1829
最新资源
- 【独家首发】秃鹰算法BES-DELM锂电池寿命SOC估计【含Matlab源码 7011期】.zip
- 【独家首发】天鹰算法AO-DELM锂电池寿命SOC估计【含Matlab源码 7010期】.zip
- 【独家首发】天鹰算法AO-DELM锂电池寿命SOC估计【含Matlab源码 7010期】.zip
- 【独家首发】雾凇算法RIME-DELM锂电池寿命SOC估计【含Matlab源码 7012期】.zip
- 【独家首发】雾凇算法RIME-DELM锂电池寿命SOC估计【含Matlab源码 7012期】.zip
- 【独家首发】雪融算法SAO-DELM锂电池寿命SOC估计【含Matlab源码 7015期】.zip
- 【独家首发】雪融算法SAO-DELM锂电池寿命SOC估计【含Matlab源码 7015期】.zip
- 【独家首发】向量加权平均算法INFO-DELM锂电池寿命SOC估计【含Matlab源码 7013期】.zip
- 【独家首发】向量加权平均算法INFO-DELM锂电池寿命SOC估计【含Matlab源码 7013期】.zip
- 【独家首发】星雀算法NOA-DELM锂电池寿命SOC估计【含Matlab源码 7014期】.zip
- 【独家首发】星雀算法NOA-DELM锂电池寿命SOC估计【含Matlab源码 7014期】.zip
- 【独家首发】鱼鹰算法OOA-DELM锂电池寿命SOC估计【含Matlab源码 7019期】.zip
- 【独家首发】遗传算法GA-DELM锂电池寿命SOC估计【含Matlab源码 7016期】.zip
- 【独家首发】引力搜索算法GSA-DELM锂电池寿命SOC估计【含Matlab源码 7018期】.zip
- 【独家首发】引力搜索算法GSA-DELM锂电池寿命SOC估计【含Matlab源码 7018期】.zip
- 【独家首发】蚁狮算法ALO-DELM锂电池寿命SOC估计【含Matlab源码 7017期】.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)