有本书叫做《o'reilly.java.message.service.pdf》,下步打算先学习下这个。
解决方案 »
- 如何将ACCESS表复制到SQLSERVER2K中?
- 存储过程
- Struts2.0+Hibernate3.0+Spring2.0 出现了Hibernate的could not insert 异常!!
- struts2的s:iterator问题
- 跪求, JOTM+Hibernate+MySQL详细配置过程。
- 高并发访问的大型BBS,都是每刷新一下调一次数据库?
- struts问题 急!!!!!!!
- 一台服务器多个web服务器的配置(apache+tomcat)500分求解
- webservice xifre客户端调用出错
- 20年来的自信被EJB给粉碎了。。。晤呼。。。救我!
- java 文件上传下载
- 信息机二次开发
但是使用jms服务的代码就比较简单了。
· 初始化JNDI Tree
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, PROVIDER_URL);
return new InitialContext(env);
· lookup ConnectionFactory
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
· lookup Destination
queue = (Queue) ctx.lookup(queueName);
· 用 ConnectionFactory 创建Connection
qcon = qconFactory.createQueueConnection();
· 用 Connection 创建一个Session
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
· 用 Session 和 Destination 创建MessageProducer
qsender = qsession.createSender(queue);
· 启动 Connection。
qcon.start();
· 发送消息
msg = qsession.createTextMessage();
msg.setText(message);
qsender.send(msg);