spring和jms的事务开启

cylenve 2012-07-24 05:20:20
我只能发100分的帖子啊?如果大侠能解决问题,在追加100分!!!

jms的createQueueSession的第一个参数设置成true的时候,来开启session事务,
但是getTransacted()返回的一直是false。


================ java ============================================
import javax.jms.Connection;
import javax.jms.Session;

Connection connection = ((QueueConnectionFactory)this.getConnectionFactory()).createQueueConnection();
Session jmsSession = ((QueueConnection) connection).createQueueSession(true, 0);

jmsSession.getTransacted(); ---------------------------------- false

============= wmq.jmsra-ds.xml =====================================
<connection-factories>

<!-- mbeans defining JCA administered objects -->
<mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=ivtqueue">

<!-- Bind this AdminObject with the JNDI name IVTQueue -->
<attribute name="JNDIName">IVTQueue</attribute>

<!-- this MBean depends on the WebSphere MQ resource adapter -->
<depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>

<!-- this admin object is a javax.jms.Queue -->
<attribute name="Type">javax.jms.Queue</attribute>

<!--
Configuration for Queue TEST.QUEUE
If you need to specify a specific queue manager add the following
baseQueueManagerName=ExampleQM
-->
<attribute name="Properties">
baseQueueName=XXXX
baseQueueManagerName=QMXX
</attribute>
</mbean>

<!-- JCA Connection factory definitions -->
<tx-connection-factory>
<!-- Bind this ConnectionFactory with the JNDI name WSMQJmsXA -->
<jndi-name>WSMQJms</jndi-name>

<!-- Indicate that the connection factory supports only local transactions -->
<local-transaction/>
<!-- Indicate that the connection factory supports XA transactions -->
<!-- <xa-transaction/> -->

<!-- rar-name is the actual RAR file name, in this case wmq.jmsra.rar -->
<rar-name>wmq.jmsra.rar</rar-name>

<!-- connection-definition is the ConnectionFactory interface
defined in the ra.xml -->
<connection-definition>javax.jms.QueueConnectionFactory</connection-definition>

<!-- Tell JBoss not to prefix the jndi name of the CF with the java: context and thus allow it to be looked up externally-->
<!--<use-java-context>false</use-java-context>-->

<!--
Configuration for the ConnectionFactory. This defines the channel, hostname, port,
queueManager, and transportType properties for a client (TCP/IP) connection to WMQ
-->
<config-property name="channel" type="java.lang.String">SYSTEM.AUTO.SVRCONN</config-property>
<config-property name="hostName" type="java.lang.String">192.168.0.110</config-property>
<config-property name="port" type="java.lang.String">1414</config-property>
<config-property name="queueManager" type="java.lang.String">QMXX</config-property>
<config-property name="transportType" type="java.lang.String">CLIENT</config-property>
<config-property name="CCSID" type="java.lang.String">1208</config-property>

<!-- define security domain -->
<security-domain-and-application>JmsXARealm</security-domain-and-application>
</tx-connection-factory>
</connection-factories>

========================== applicationContext.xml ===================
<bean id="AAA" class="co.base.JMSQueueConnector">
<property name="config" ref="JMSDestProperty" />
<property name="jmsTemplate">
<bean name="jmsTemplate" class = "co.jms.ManualTransactionJmsTemplate">
<property name="connectionFactory" ref="connectQueueFactory" ></property>
</bean>
</property>
</bean>
<jee:jndi-lookup id="connectQueueFactory" jndi-name="java:/WSMQJms" resource-ref="false" />

=======================================================================

怎么样能让createQueueSession返回的session是事务的?
Thanks!!!
...全文
294 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cylenve 2012-07-25
  • 打赏
  • 举报
回复
对了,直接把连接池配到applicationContext.xml,session就可以有事务。
bean id="connectQueueFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="channel" value="SYSTEM.AUTO.SVRCONN"></property>
<property name="transportType" value="1"></property>
<property name="queueManager" value="QMXXX"></property>
<property name="hostName" value="192.168.0.XXX"></property>
<property name="port" value="1414"></property>
<property name="CCSID" value="1208"></property>
</bean>
cylenve 2012-07-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jianlajidexiaohuo 的回复:]
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = con……
[/Quote]
有没有别的办法,ActiveMQ还要安装,客户肯定不同意。
就用jms连接ibmmq,能不能设置?
jboss中还要设置什么东西吗?????
brightyq 2012-07-24
  • 打赏
  • 举报
回复
楼主这帖似曾相识 。在哪有一模一样的。

检查下connection是否得到正确的值。
「已注销」 2012-07-24
  • 打赏
  • 举报
回复
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://localhost:61616");
Connection connection = connectionFactory.createConnection();
connection.start();
Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
System.out.println("aaaaa:"+session.getTransacted());
cylenve 2012-07-24
  • 打赏
  • 举报
回复
自己顶个

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧