浏览 7549 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-06-16
I had a difficult time getting a Spring JmsTemplate configured and connected to my OpenJMS server. There wasn't any complete examples in the Spring documentation. Eventually I did get it working, and I am posting the results here in the hopes that someone else will find it useful. This configuration fetches the OpenJMS QueueConnectionFactory from JNDI, and sets up a Spring JMS JNDI Destination Resolver to pull named destinations (queues or topics) out of JNDI. Pass the jmsQueueTemplate bean into your own objects as a property, and you can use it to send and receive from any OpenJMS queue. Application Context XML <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//Spring//DTD Bean//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <!-- Application Context --> <beans> <!-- JNDI Environment Template --> <bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial">org.exolab.jms.jndi.InitialContextFactory</prop> <prop key="java.naming.provider.url">rmi://localhost:1099/</prop> </props> </property> </bean> <!-- Internal JMS Queue Connection Factory --> <bean id="internalJmsQueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate"> <ref bean="jndiTemplate" /> </property> <property name="jndiName"> <value>JmsQueueConnectionFactory</value> </property> </bean> <!-- Spring Wrapped JMS Queue Connection Factory --> <bean id="jmsQueueConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory102"> <property name="targetConnectionFactory"> <ref bean="internalJmsQueueConnectionFactory" /> </property> <property name="pubSubDomain"> <value>false</value> </property> </bean> <!-- JMS Destination Resolver --> <bean id="jmsDestinationResolver" class="org.springframework.jms.support.destination.JndiDestinationResolver"> <property name="jndiTemplate"> <ref bean="jndiTemplate" /> </property> <property name="cache"> <value>true</value> </property> </bean> <!-- JMS Queue Template --> <bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate102"> <property name="connectionFactory"> <ref bean="jmsQueueConnectionFactory" /> </property> <property name="destinationResolver"> <ref bean="jmsDestinationResolver" /> </property> <property name="pubSubDomain"> <value>false</value> </property> <property name="receiveTimeout"> <value>2000</value> </property> </bean> </beans> 原文地址 请大家试试。 现在我正在开发JMS方面的东东,有什么时间可以和我联系。我的BLOG 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-06-17
到底要说什么?
|
|
返回顶楼 | |
发表时间:2005-06-22
为什么大家没有人来试一试呀,我认为openjms是消息服务入门级的消息中间件,我已经测试成功他的P2P,PUB/SUB时还有问题,就是不能够正常订阅到消息。
开发环境:WSAD Spring Version:1.2.1 上面的配置文件还有一个很重要的就是:请把你的BEAN依赖注入到Spring当中,举例如下。 <code> 一楼的JAVA代码 (略) <bean id="openjmsimpl" class="com.throuhout.j2eemodel.jms.openjms.openjmsimpl"> <property name="jmsTemplate"> <ref bean="jmsQueueTemplate" /> </property> </bean> </code> 我在接收订阅时有错误产生: Unhandled Exception thrown: class java.lang.NullPointerException 希望大家来帮助我!!!!!!!! 你可以参考我的BLOG EAI类别里的两个示例进行操作。 |
|
返回顶楼 | |
发表时间:2005-06-24
终于发现OPENJMS服务器,慢的要死,建议:消息服务入门者可以用作参考,不过他的性能真是不敢恭维。
发送1万条记录能够占用差不多1个小时,唉,JBOSS也只有了3分钟不到呀。实际OPENJMS就是拿来玩的。 呵呵。 ---------------------------------------- 不过OPENJMS使用MYSQL时,速度有了质的提高,测试结果如下: JBOSS,前1119581807500 后1119581826609 差值:19109 OPENJMS SEND前:1119594114937 SEND后:1119594201828 差值:86891 测试代码: Date now = new Date(); long nowLong = now.getTime(); System.out.println(nowLong); for (int i = 0 ; i < 10000 ; i ++){ x.testJmsSend(); } Date now2 = new Date(); long nowLong2 = now2.getTime(); System.out.println(nowLong2); |
|
返回顶楼 | |
发表时间:2005-06-24
我使用openjms的时候发现另一个问题:占用硬盘。使用object message,大概2万的消息能占掉1G的空间,这样下去很快服务器就会挂
不过我没有测试用db比如mysql来做持久,也许能解决这两个问题 |
|
返回顶楼 | |