来源:网络整理 时间:2015-12-17 关键词:队列,Spring,连接数据库,Annotation,JDBC
本篇文章主要介绍了"SpringMVC+MyBatis+JMS+JTA(分布式事务)",主要涉及到队列,Spring,连接数据库,Annotation,JDBC方面的内容,对于软件工程感兴趣的同学可以参考一下:
SpringMVC+MyBatis 相信已经是现在企业开发中常用技术了。
因为一些需求,我们需要集成JMS(我使用的是ActiveMQ),大家应该都知道,MQ...
<beansxmlns="http://www.Springframework.org/schema/beans"xmlns:context="http://www.Springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:amq="http://activemq.apache.org/schema/core"xmlns:jms="http://www.Springframework.org/schema/jms"xmlns:tx="http://www.Springframework.org/schema/tx"xsi:schemaLocation="http://www.Springframework.org/schema/beans
http://www.Springframework.org/schema/beans/Spring-beans-4.1.xsd
http://www.Springframework.org/schema/context
http://www.Springframework.org/schema/context/Spring-context-4.1.xsd
http://www.Springframework.org/schema/jms
http://www.Springframework.org/schema/jms/Spring-jms-4.1.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core-5.13.0.xsd
http://www.Springframework.org/schema/tx
http://www.Springframework.org/schema/tx/Spring-tx-4.1.xsd"><amq:redeliveryPolicyid="redeliveryPolicy"maximumRedeliveries="6" /><amq:prefetchPolicyid="prefetchPolicy"queuePrefetch="5"topicPrefetch="5" /><amq:xaConnectionFactoryid="jmsXaConnectionFactory"brokerURL="${activemq.brokerURL}"userName="${activemq.username}"password="${activemq.password}"redeliveryPolicy="#redeliveryPolicy"alwaysSessionAsync="false"alwaysSyncSend="true"prefetchPolicy="#prefetchPolicy"/><beanid="amqConnectionFactory"class="com.atomikos.jms.AtomikosConnectionFactoryBean"init-method="init"destroy-method="close"><propertyname="uniqueResourceName"value="XAactiveMQ"/><propertyname="xaConnectionFactory"ref="jmsXaConnectionFactory"/><propertyname="poolSize"value="100"/>bean><beanid="jmsQueueTemplate"class="org.Springframework.jms.core.JmsTemplate"><constructor-argref="amqConnectionFactory" /><propertyname="pubSubDomain"value="false" />bean><beanid="jmsTopicTemplate"class="org.Springframework.jms.core.JmsTemplate"><constructor-argref="amqConnectionFactory" /><propertyname="pubSubDomain"value="true" />bean><amq:queueid="queueReceiver2ResponseDestination"physicalName="test.queue2.response" /><jms:listener-container
destination-type="queue"container-type="default"connection-factory="amqConnectionFactory"error-handler="jmsErrorHandler"acknowledge="auto"><jms:listenerdestination="xinge.queue.push"ref="xgMessageReceiver"concurrency="5-100" /><jms:listenerdestination="xinge.queue.push.device.multiple"ref="xgMessageReceiverMultiple"concurrency="5-100" />jms:listener-container><jms:listener-container
destination-type="queue"container-type="default"connection-factory="amqConnectionFactory"transaction-manager="jtaTransactionManager"error-handler="jmsErrorHandler"acknowledge="transacted"><jms:listenerdestination="xinge.queue.push.invokelog"ref="xgMessageReceiverInvokeLog"concurrency="5-100" />jms:listener-container><beanid="xingeApp"class="com.tencent.xinge.XingeApp"><constructor-argindex="0"value="2100170086"/><constructor-argindex="1"value="2d257b10220bc3849743ffe0e9bd233a"/>bean>beans>
4、Spring-mvc.xml
<beansxmlns="http://www.Springframework.org/schema/beans"xmlns:aop="http://www.Springframework.org/schema/aop"xmlns:context="http://www.Springframework.org/schema/context"xmlns:mvc="http://www.Springframework.org/schema/mvc"xmlns:tx="http://www.Springframework.org/schema/tx"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.Springframework.org/schema/aop
http://www.Springframework.org/schema/aop/Spring-aop-4.0.xsd
http://www.Springframework.org/schema/beans
http://www.Springframework.org/schema/beans/Spring-beans-4.0.xsd
http://www.Springframework.org/schema/context
http://www.Springframework.org/schema/context/Spring-context-4.0.xsd
http://www.Springframework.org/schema/mvc
http://www.Springframework.org/schema/mvc/Spring-mvc-4.0.xsd
http://www.Springframework.org/schema/tx
http://www.Springframework.org/schema/tx/Spring-tx-4.0.xsd"><mvc:Annotation-driven /><mvc:resourceslocation="/resources/"mapping="/resources/**"/><context:component-scanbase-package="com.hvgroup.zhuhai10086.jms" ><context:include-filtertype="Annotation"expression="org.Springframework.stereotype.Controller"/>context:component-scan><beanclass="org.Springframework.web.servlet.view.InternalResourceViewResolver"><propertyname="prefix"value="/WEB-INF/views/" /><propertyname="suffix"value=".jsp" /><propertyname="order"value="1" />bean>beans>
5、config.properties