- 浏览: 348310 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
孙大圣123:
大神,你分享的castor dtd文件中没有field-han ...
Castor (二) -- 自定义映射 -
ananeye:
建议举些通俗的例子,说明下。光这样讲,不好懂。
ORACLE 索引原理 -
度_java:
1.不在不同的机器上实现集群功能,除非他们的时钟同步精确到秒。 ...
Quartzs -- Quartz.properties 配置 -
2047699523:
可以参考最新的文档:如何在eclipse jee中检出项目并转 ...
MAVEN3--(三)创建MAVEN项目 -
qgm168:
写的不错,借用啦,哈哈,多谢!
自定义POI EXCEL模板
1. Spring JMS整合类图
2. 程序
- applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- MQ Provider -->
<bean name="actualJMSConnFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/NormalConnectionFactory"/>
</bean>
<bean name="queueSendTo" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/queue/sender"/>
</bean>
<bean name="queueReceiveFrom" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/queue/receiver"/>
</bean>
<!-- Spring JMS -->
<bean name="jmsConnFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory" ref="actualJMSConnFactory"/>
</bean>
<bean name="sender" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsConnFactory"/>
<property name="defaultDestination" ref="queueSendTo"/>
</bean>
<bean name="receiver" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="jmsConnFactory"/>
<property name="defaultDestination" ref="queueReceiveFrom"/>
<property name="receiveTimeout" value="3000"/>
</bean>
<!-- Application -->
<bean name="jmsSender" class="springJMS.JMSSender">
<property name="sender" ref="sender"/>
</bean>
<bean name="jmsReceiver" class="springJMS.JMSReceiver">
<property name="receiver" ref="receiver"/>
</bean>
<!-- ApplicationContext Aware -->
<bean name="appContext" class="springJMS.AppContext"/>
</beans>
- JMSSender
package springJMS;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
public class JMSSender {
private JmsTemplate sender;
/**
* @return the sender
*/
public JmsTemplate getSender() {
return sender;
}
/**
* @param sender the sender to set
*/
public void setSender(JmsTemplate sender) {
this.sender = sender;
}
public void send(final String msg) {
sender.send(new MessageCreator() {
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(msg);
}
});
}
}
- JMSReceiver
package springJMS;
import javax.jms.Message;
import org.springframework.jms.core.JmsTemplate;
public class JMSReceiver {
private JmsTemplate receiver;
/**
* @return the receiver
*/
public JmsTemplate getReceiver() {
return receiver;
}
/**
* @param receiver the receiver to set
*/
public void setReceiver(JmsTemplate receiver) {
this.receiver = receiver;
}
public Message receive() {
return receiver.receive();
}
}
- AppContext
package springJMS;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
public class AppContext implements ApplicationContextAware {
private static ApplicationContext appContext;
public static Object getBean(String name) {
return appContext.getBean(name);
}
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
appContext = applicationContext;
}
}
- springJMS.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<jsp:directive.page import="springJMS.JMSSender"/>
<jsp:directive.page import="springJMS.AppContext"/>
<jsp:directive.page import="springJMS.JMSReceiver"/>
<jsp:directive.page import="javax.jms.Message"/>
<jsp:directive.page import="javax.jms.TextMessage"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
JMSSender sender = (JMSSender) AppContext.getBean("jmsSender");
JMSReceiver receiver = (JMSReceiver) AppContext.getBean("jmsReceiver");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>JMS Queue Test</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%sender.send("Nice to meet u!"); %>
<%="Send : Nice to meet u!" %><br>
<%
Message message = receiver.receive();
if (message instanceof TextMessage) {
%>
<%="Receive : " + ((TextMessage) message).getText() %>
<%
}
%>
</body>
</html>
3.测试
开启MQ,创建对应的QUEUE,运行http://orange5458.iteye.com/admin/blogs/988495
的消息处理器,启动TOMCAT,进入springJMS.jsp,刷新。
4.参考资料
Spring开发者手册 http://orange5458.iteye.com/admin/blogs/981099
发表评论
-
自定义POI EXCEL模板
2013-07-01 17:51 23191.背景 项目中需要将相关数据导出为EXCEL文件,该文 ... -
POI操作EXCEL
2013-07-01 15:55 9801.简介 Apache POI是Apache软件基金会的开 ... -
JSON-LIB
2013-06-30 15:44 16371.关于JSON JSON(JavaScript Obj ... -
Jasperreport应用小结
2013-06-19 23:15 14281.简介 JasperReport是一 ... -
JAVA实现FTP
2013-06-09 09:05 151061.关于FTP FTP:File Transfe ... -
Digester解析的顺序
2013-03-11 18:07 15091.说明 本文将通过一段代码来说明Digester解析X ... -
ONGL介绍
2012-10-16 17:02 58941.简介 OGNL:Object Graph Navi ... -
MyBatis(一)----基础使用
2012-06-10 22:24 9281.简介 --MyBatis是支持普通SQL查询,存储 ... -
SMOOKS--XSL
2012-06-07 13:33 30931.简介 Smooks是一个用于出力XML和非XML数 ... -
Log4j
2012-05-25 15:28 10811。简介 Log4j是一个应 ... -
commons-logging
2012-05-23 22:25 1059一。简介 commons-logging是Apache下的一 ... -
JFreeChart -- Web应用
2012-01-06 00:26 10211) Model index.jsp < ... -
JUnit -- 分析
2011-12-11 18:08 9961.类结构图 Assert : 大量的ass ... -
Quartzs -- JDBC-JobStore - Oracle 实现 + Cluster
2011-09-13 16:44 4489数据库 从%QUARTZ_HOME%/docs/dbTa ... -
Quartzs -- Quartz.properties 配置
2011-09-13 11:23 46269文件加载位置 默认:优先顺序 Classpath: ... -
StringTemplate学习笔记(四) StringTemplateGroup文件
2011-08-27 10:31 3506一,简介 StringTemplateGroup ... -
StringTemplate学习笔记(三) st文件加载
2011-08-22 22:40 4372一,简介 ST通过StringTemplateGr ... -
StringTemplate学习笔记(二) 语法
2011-08-21 16:11 10951一,分隔符,注释 <...>貌似只能在Stri ... -
StringTemplate学习笔记(一) 简介
2011-08-21 09:47 2607一,简介 StringTemplate(简称ST ... -
Castor (二) -- 自定义映射
2011-08-03 23:33 39131.概述 Castor的自定义映射关系通过XML设置。 ...
相关推荐
主要介绍了Spring Boot基于Active MQ实现整合JMS,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
active core mq geronimo jms jar.rar 包含 activeio-core-3.1.2.jar activemq-core-5.4.0.jar apache-activemq-4.1.0-incubator.jar geronimo-j2ee-management_1.1_spec-1.0.1.jar geronimo-jms_1.1_spec-1.1.1.jar...
active mq 实战教程,写的很不错,拿来分享
spring_jms是基于Maven+Spring+JMS+Active入门级实例.
一个active和spring整合的例子,方便大家在做项目的时候有个例子可以参考
包含两个示例中,第一个示例须要运行单独MQ(Apache Active MQ 5.15.0以下的版本)。第二个示例不需要运行单独的MQ。 有兴趣的朋友可以看看。两个示例运用的不同的方法去实现的。
Active MQ 与 WebSphere MQ 高可用性和管理分析。
Active MQ C++实现通讯 X86 librariy:CMS (stands for C++ Messaging Service)类似于JMS API用于同Message Brokers通讯(例如Active MQ)。 APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如...
Active MQ 基础知识思维导图。主要是JMS总结介绍。用于学习和复习
active MQ maven POM方式 初学者
Active MQ in Action,英文版。主要是ActiveMQ,manning
Jfinal -active mq: 消费:extends JFinalQueueConsumer 生产:JFinalQueue.sendMessage(queueName, message);
active_mq_mvc 源码,由一段if...else..判断引起的代码重构...,主要讲设计思想,以及设计模式,合理的运用反射,极度的省略了代码
下面小编就为大家带来一篇JMS 之 Active MQ 的消息传输(详解)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
集成了所有active MQ资源,应用于windows和linux即时通信
active mq的学习手册,例子等。你可以一步步地上手。
Camel IBM Websphere MQ 到 Active MQ 桥接路由 先决条件 IBM 为安装在 Fuse 上的 MQ 客户端提供了 OSGi jar 文件IBM_MQ_INSTALL_DIR/java/lib/OSGi 运行 AMQ 代理 带有填充属性的 JBOSS_FUSE_INSTALL_DIR/etc/ 中...
基于Spring+JMS+ActiveMQ+Tomcat,做一个Spring4.1.0和ActiveMQ5.11.1整合实例,实现了Point-To-Point的异步队列消息和PUB/SUB(发布/订阅)模型,简单实例,不包含任何业务。
ActiveMQ is the most popular and powerful ...Bus.ActiveMQ 是一个完全支持JMS1.1 和J2EE 1.4 规范的JMS Provider 实现,尽管JMS 规范出台 已经是很久的事情了,但是JMS 在当今的J2EE 应用中间仍然扮演着特殊的地位。
开发active-mq的良好帮助指导手册