- 浏览: 7258501 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (1546)
- 企业中间件 (236)
- 企业应用面临的问题 (236)
- 小布Oracle学习笔记汇总 (36)
- Spring 开发应用 (54)
- IBatis开发应用 (16)
- Oracle基础学习 (23)
- struts2.0 (41)
- JVM&ClassLoader&GC (16)
- JQuery的开发应用 (17)
- WebService的开发应用 (21)
- Java&Socket (44)
- 开源组件的应用 (254)
- 常用Javascript的开发应用 (28)
- J2EE开发技术指南 (163)
- EJB3开发应用 (11)
- GIS&Mobile&MAP (36)
- SWT-GEF-RCP (52)
- 算法&数据结构 (6)
- Apache开源组件研究 (62)
- Hibernate 学习应用 (57)
- java并发编程 (59)
- MySQL&Mongodb&MS/SQL (15)
- Oracle数据库实验室 (55)
- 搜索引擎的开发应用 (34)
- 软件工程师笔试经典 (14)
- 其他杂项 (10)
- AndroidPn& MQTT&C2DM&推技术 (29)
- ActiveMQ学习和研究 (38)
- Google技术应用开发和API分析 (11)
- flex的学习总结 (59)
- 项目中一点总结 (20)
- java疑惑 java面向对象编程 (28)
- Android 开发学习 (133)
- linux和UNIX的总结 (37)
- Titanium学习总结 (20)
- JQueryMobile学习总结 (34)
- Phonegap学习总结 (32)
- HTML5学习总结 (41)
- JeeCMS研究和理解分析 (9)
最新评论
-
lgh1992314:
[u][i][b][flash=200,200][url][i ...
看看mybatis 源代码 -
尼古拉斯.fwp:
图片根本就不出来好吧。。。。。。
Android文件图片上传的详细讲解(一)HTTP multipart/form-data 上传报文格式实现手机端上传 -
ln94223:
第一个应该用排它网关吧 怎么是并行网关, 并行网关是所有exe ...
工作流Activiti的学习总结(八)Activiti自动执行的应用 -
ZY199266:
获取不到任何消息信息,请问这是什么原因呢?
ActiveMQ 通过JMX监控Connection,Queue,Topic的信息 -
xiaoyao霄:
DestinationSourceMonitor 报错 应该导 ...
ActiveMQ 通过JMX监控Connection,Queue,Topic的信息
在META-INF中配置如下:
Context.xml文件內容:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jms/ConnectionFactory" auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="vm://localhost"
brokerName="localhost"
useEmbeddedBroker="false"
/>
<Resource name="jms/Queue"
auth="Container"
type="org.apache.activemq.command.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TEST.FOO"
/>
<Resource name="jms/Topic" auth="Container"
type="org.apache.activemq.command.ActiveMQTopic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TEST.FOO.QUEUE"
/>
</Context>
JMS实现类:
package cn.com.vnvtrip.flex.message;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import javax.jms.JMSException;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.TopicConnection;
import javax.jms.TopicPublisher;
import javax.jms.TopicSession;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQTopic;
/**
*
* @author longgangbai
*
*/
public class FlexMessageSender implements Runnable {
private Context envCtx = null;
private ActiveMQConnectionFactory connectionFactory;
private TopicConnection connection;
private TopicSession session;
private ActiveMQTopic destination;
private TopicPublisher publisher;
private Random random = new Random();
private int i = 0;
private void initializer() {
Context initCtx = null;
try {
initCtx = new InitialContext();
connectionFactory = (ActiveMQConnectionFactory) initCtx
.lookup("java:comp/env/jms/ConnectionFactory");
System.out.println("connectionFactory =" + connectionFactory);
destination = (ActiveMQTopic) initCtx
.lookup("java:comp/env/jms/Topic");
System.out.println("destination =" + destination);
connection = connectionFactory.createTopicConnection();
session = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
publisher = session.createPublisher(destination);
connection.start();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void send() {
try {
TextMessage message = session.createTextMessage();
String value = String.valueOf(random.nextInt(100));
message.setText(value);
publisher.publish(message);
System.out.println("send " + value + " ok.");
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void sendObj() {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
String time = simpleDateFormat.format(new Date());
String index = String.valueOf(i++);
String x = String.valueOf(random.nextInt(100));
OrderVO bean = new OrderVO();
bean.setId(index);
bean.setName(time);
bean.setValue(x);
ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setObject(bean);
publisher.send(objectMessage);
System.out.println("send obj x=" + x + "-------------" + time);
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/
public void run() {
try {
initializer();
connection.start();
send();
while (true) {
sendObj();
// int qq = random.nextInt(10);
Thread.sleep(1000);
}
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
web.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>jmsServlet</servlet-name>
<servlet-class>cn.com.vnvtrip.flex.message.JMSMessageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>jmsServlet</servlet-name>
<url-pattern>/jmsServlet</url-pattern>
</servlet-mapping>
<description>
</description>
<resource-ref>
<description>topic/MyTopic</description>
<res-ref-name>jms/topic/MyTopic</res-ref-name>
<res-type>org.apache.activemq.command.ActiveMQTopic</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<description>
</description>
<resource-ref>
<description>ConnectionFactory</description>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>org.apache.activemq.ActiveMQConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
使用一個Servlet测试JMS
package cn.com.vnvtrip.flex.message;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class JMSMessageServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public JMSMessageServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* 测试JMS
*/
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
FlexMessageSender meesagesender = new FlexMessageSender();
Thread thread = new Thread(meesagesender);
thread.start();
out.println("flex message Thread ....");
out.flush();
out.close();
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException
* if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
发表评论
-
【转】Django resources
2014-01-23 14:35 10719Django resources This page li ... -
使用国内镜像源来加速python pypi包的安装
2014-01-16 11:16 197582pipy国内镜像目前有: http://pypi.d ... -
[转 ]vagrant使用简介
2014-01-10 13:53 256191> 简介: vagrant提供了易于配置,重复性 ... -
[转]在Java中调用Python
2014-01-07 13:08 9145在执行之前都需要把jython对应的包加载进去,这个是必须的 ... -
[转]Eclipse配置PyDev插件
2014-01-02 14:25 2787安装python解释器 安装PyDev: 首 ... -
RestFuse的研究(五) Http请求的封装
2014-06-14 15:50 3524在RestFuse中封装了Http请 ... -
RestFuse的研究(四) Junit的Statement的分析
2013-12-06 11:46 1610在RestFuse提供了多种单 ... -
RestFuse的研究(三) Junit的Rule的使用和分析
2013-12-06 11:01 2194在junit中定义一些可以公用的规则(R ... -
RestFuse的研究(二) Junit的Runner的分类和模式
2013-12-06 10:40 1565在Junit4中的调用JunitCore可以采 ... -
RestFuse的研究(一) HttpJunitRunner的实现
2013-12-06 10:11 1701在RestFuse是一种针对Rest We ... -
[转]An open-source JUnit extension to test HTTP/REST APIs
2013-12-06 09:57 1056http://developer.eclipsesource ... -
TestNG简单的学习(十三)TestNG中Junit的实现
2013-12-04 09:00 3294TestNG和junit的整合 ... -
TestNG简单的学习(十二)TestNG运行
2013-12-03 09:08 51456文档来自官方地址: ... -
TestNG简单的学习(十一)TestNG学习总结
2013-12-03 09:08 14001最近一直在学习关于TestNG方面的知识,根 ... -
TestNG简单的学习(十)TestNG @Listeners 的使用
2013-12-03 09:07 8630TestNG官方网站: http://testng.or ... -
TestNG简单的学习(九)TestNG Method Interceptors 的使用
2013-12-03 09:07 2662TestNG官方网站: http://testng ... -
TestNG简单的学习(八)TestNG Annotation Transformers 的使用
2013-12-03 09:07 2762TestNG官方网站: http://testng.or ... -
TestNG简单的学习(七)TestNG编程方式运行
2013-12-02 09:22 2402TestNG官方网站: http://testng.or ... -
TestNG简单的学习(六)测试工厂注释的使用
2013-12-02 09:22 2721TestNG官方网站: http://testng.or ... -
TestNG简单的学习(五)参数化测试数据的定制
2013-12-02 09:22 2647TestNG官方网站: http://testng.or ...
相关推荐
在JBOSS 环境中配置JMS,在程序中可以通过JNDI 获取连接,如消息启动Bean 就可以通过JNDI获取:@MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue ...
NULL 博文链接:https://bijian1013.iteye.com/blog/2304181
NULL 博文链接:https://bijian1013.iteye.com/blog/2304111
主要介绍了JNDI,JTA和JMS的相关内容,包括中文释义,概念解释等,需要的朋友可以了解下。
rmi-jndi-ldap-jrmp-jmx-jms rmi,jndi,ldap,jrmp,jmx,jms一些演示测试
private static String JMS_FACTORY = "JNDI_JMS_Connection_Factory"; private static String QUEUE = null; private QueueConnectionFactory qconFactory; private QueueConnection qcon; private ...
在tomcat 下的context.xml文件中加入 auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory" factory="org.apache.activemq.jndi....
里面包含了:JMS、RPC、Ajax、SOAP、WSDL、JPA、ORM、mvc和JNDI九个术语的详解。认真读完本文,将显著提高你对JavaEE的认识。
JMS 在系统中的应用,可以修改后应用于系统中。
sprin jms activemq 测试 两个 一个是jndi 一个是activemq
在Tomcat的conf/context.xml中的元素里面加上如下配置: auth="Container" type="org.apache.activemq.ActiveMQConnectionFactory" description="JMS Connection Factory" factory="org.apache.activemq....
was6.0的lib,文件列表为: CL3Export.jar CL3Nonexport.jar ...com.ibm.mq.jms.Nojndi.jar ...commonservices.jar connector.jar ...jms.jar jndi.jar jta.jar ldap.jar postcard.jar providerutil.jar rmm.jar
JMS_Glassfish-3-Server 在 Glassfish 3 服务器中实现 JMS管理系统: 它是一个用于创建、读取和发送消息的 API。 它是一个消息服务提供者,用于从一个应用程序向另一个应用程序发送和接收消息。 通常,用户向应用...
传统的使用JMSAPI进行消息传递的实现包括多个步骤,例如JNDI查询队列连接工厂和Queue资源,在实际发送和接收消息前创建一个JMS会话。Spring框架则简化了使用JEE组件(包括JMS)的任务。它提供的模板机制隐藏了典型的...
J2EE组件使用JNDI相互查找和查找所需要的资源,如JDBC和JMS连接。JMS这样的技术鼓励松散耦合,允许灵活地为工作流程建模、容易分配处理任务、可伸缩性和容错性。很多J2SE服务器应用程序也可以从这些技术和原理中受益...