package cn.epaylinks.mq.controller;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.epaylinks.mq.producer.QueueSender;
import cn.epaylinks.mq.producer.TopicSender;
@Controller
@RequestMapping("/activemq")
public class ActiveMqController
{
@Resource
QueueSender queueSender;
@Resource
TopicSender topicSender;
/**
* 发送消息到队列
* Queue队列:仅有一个订阅者会收到消息,消息一旦被处理就不会存在队列中
* @param message
* @return String
*/
@ResponseBody
@RequestMapping("queueSender")
public String queueSender(@RequestParam("message")String message)
{
String opt = "";
try
{
queueSender.send("queueMessage", message);
opt = "suc";
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
opt = e.getCause().toString();
}
return opt;
}
/**
* 发送消息到主题
* Topic主题 :放入一个消息,所有订阅者都会收到
* 这个是主题目的地是一对多的
* @param message
* @return String
*/
@ResponseBody
@RequestMapping("topicSender")
public String topicSender(@RequestParam("message")String message)
{
String opt = "";
try
{
topicSender.send("topicMessage", message);
opt = "suc";
} catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
opt = e.getCause().toString();
}
return opt;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
spring-mq.zip (41个子文件)
spring-mq
.project 1KB
src
test
resources
java
main
webapp
WEB-INF
web.xml 2KB
index.jsp 2KB
scripts
jquery-1.11.0.min.js 94KB
resources
applicationContext.xml 2KB
ActiveMQ.xml 3KB
spring-mvc.xml 2KB
log4j.properties 1KB
java
cn
epaylinks
mq
consumer
topic
TopicReceiver1.java 621B
TopicReceiver2.java 621B
queue
QueueReceiver1.java 621B
QueueReceiver2.java 621B
controller
ActiveMqController.java 2KB
producer
TopicSender.java 973B
QueueSender.java 1KB
target
m2e-wtp
web-resources
META-INF
MANIFEST.MF 115B
maven
cn.epaylinks
spring-mq
pom.properties 222B
pom.xml 3KB
classes
cn
epaylinks
mq
consumer
topic
TopicReceiver1.class 1KB
TopicReceiver2.class 1KB
queue
QueueReceiver2.class 1KB
QueueReceiver1.class 1KB
controller
ActiveMqController.class 2KB
producer
TopicSender.class 1KB
QueueSender.class 1KB
TopicSender$1.class 1KB
QueueSender$1.class 1KB
applicationContext.xml 2KB
ActiveMQ.xml 3KB
spring-mvc.xml 2KB
log4j.properties 1KB
test-classes
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.m2e.core.prefs 90B
org.eclipse.jdt.core.prefs 430B
org.eclipse.wst.validation.prefs 50B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 757B
.jsdtscope 575B
pom.xml 3KB
.classpath 1KB
共 41 条
- 1
资源评论
开发无难事
- 粉丝: 64
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功