• 大小: 11.15MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-06-18
  • 语言: Java
  • 标签: Spring  jms  ActiveMQ  整合  

资源简介

此实例基于Spring+JMS+ActiveMQ+Tomcat,注解的完整实例,包含jar包

资源截图

代码片段和文件信息

package com.tgb.SpringActivemq.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 com.tgb.SpringActivemq.mq.producer.queue.QueueSender;
import com.tgb.SpringActivemq.mq.producer.topic.TopicSender;

/**
 * 
 * @author liang
 * @description controller测试
 */
@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(“test.queue“ message);
opt = “suc“;
} catch (Exception e) {
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(“test.topic“ message);
opt = “suc“;
} catch (Exception e) {
opt = e.getCause().toString();
}
return opt;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-09-24 21:39  ActiveMQSpringDemo\
     文件        2285  2015-09-24 22:26  ActiveMQSpringDemo\.classpath
     文件        1051  2015-09-24 21:39  ActiveMQSpringDemo\.project
     目录           0  2015-09-24 21:45  ActiveMQSpringDemo\.settings\
     文件         503  2015-09-24 21:39  ActiveMQSpringDemo\.settings\.jsdtscope
     文件          57  2015-09-24 21:45  ActiveMQSpringDemo\.settings\org.eclipse.core.resources.prefs
     文件         364  2015-09-24 21:39  ActiveMQSpringDemo\.settings\org.eclipse.jdt.core.prefs
     文件         506  2015-09-24 21:39  ActiveMQSpringDemo\.settings\org.eclipse.wst.common.component
     文件         345  2015-09-24 21:39  ActiveMQSpringDemo\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2015-09-24 21:39  ActiveMQSpringDemo\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2015-09-24 21:39  ActiveMQSpringDemo\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2015-09-24 21:39  ActiveMQSpringDemo\build\
     目录           0  2015-09-26 14:50  ActiveMQSpringDemo\build\classes\
     文件        3454  2015-09-26 14:50  ActiveMQSpringDemo\build\classes\ActiveMQ.xml
     文件        1599  2015-09-24 23:28  ActiveMQSpringDemo\build\classes\applicationContext.xml
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\tgb\
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\
     目录           0  2015-09-26 13:06  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\controller\
     文件        1847  2015-09-26 12:56  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\controller\ActivemqController.class
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\
     目录           0  2015-09-26 11:15  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\queue\
     文件        1151  2015-09-26 11:15  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\queue\QueueReceiver1.class
     文件        1151  2015-09-25 15:48  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\queue\QueueReceiver2.class
     目录           0  2015-09-26 11:16  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\topic\
     文件        1151  2015-09-26 11:16  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\topic\TopicReceiver1.class
     文件        1151  2015-09-25 15:48  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\consumer\topic\TopicReceiver2.class
     目录           0  2015-09-25 15:47  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\producer\
     目录           0  2015-09-25 15:48  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\producer\queue\
     文件        1113  2015-09-25 22:25  ActiveMQSpringDemo\build\classes\com\tgb\SpringActivemq\mq\producer\queue\QueueSender$1.class
............此处省略56个文件信息

评论

共有 条评论