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";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Spring-rabbitMQ-master.zip (42个子文件)
Spring-rabbitMQ-master
pom.xml 2KB
src
main
resources
application.properties 236B
templates
demo.html 8KB
static
css
bootstrap-theme.css 21KB
bootstrap.css.map 358KB
bootstrap.min.css 111KB
bootstrap.css 134KB
bootstrap-theme.min.css 19KB
bootstrap-theme.css.map 41KB
img
1.png 15KB
2.png 20KB
4.png 26KB
3.png 25KB
fonts
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.ttf 40KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.svg 61KB
js
npm.js 484B
bootstrap.min.js 34KB
bootstrap.js 64KB
java
boot
spring
config
ProducerConsumerConfig.java 523B
DirectExchangeConfig.java 1KB
TopicExchangeConfig.java 1KB
PublishSubscribeConfig.java 1KB
po
Mail.java 941B
TopicMail.java 344B
rabbitMQ
listener
SubscribeListener2.java 439B
DirectListener1.java 432B
QueueListener1.java 417B
TopicListener1.java 514B
TopicListener2.java 517B
SubscribeListener1.java 439B
DirectListener2.java 432B
QueueListener2.java 415B
Application.java 292B
controller
RabbitMQController.java 2KB
service
Producer.java 171B
Publisher.java 370B
impl
ProducerImpl.java 618B
PublisherImpl.java 771B
.gitignore 409B
封面.png 192KB
共 42 条
- 1
资源评论
m0_72731342
- 粉丝: 4
- 资源: 1829
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功