ActiveMQ 설정

4568 단어 activemq
<beans xmlns="http://www.springframework.org/schema/beans" 
  xmlns:amq="http://activemq.apache.org/schema/core"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
  
  
<!-- ------     :      ------->
<!-- 1.   ActiveMQ Broker      JVM           ,
       spring     ,ActiveMQ embedded Broker      。
-->
	<amq:broker useJmx="false" persistent="true">
	 <!-- 2.        spring listenerContainer,        ,          -->
		<amq:persistenceAdapter>
			<amq:amqPersistenceAdapter directory="d:/iteye/amq" />
		</amq:persistenceAdapter>
		<amq:transportConnectors>
			<amq:transportConnector uri="tcp://localhost:0" />
		</amq:transportConnectors>
	</amq:broker>
<!--      activeMQ 
	<amq:connectionFactory id="jmsConnectionFactory"
		brokerURL="tcp://localhost:61616?wireFormat.maxInactivityDuration=0"
	/>
-->
<!--  
	2.   (A)ConnectionFactory     
	           Broker JVM embedded   URL :vm://localhost 
-->
	<amq:connectionFactory id="jmsConnectionFactory"
		brokerURL="vm://localhost" />

<!--
	 3   (B)Queue      Queue  
-->
	<amq:queue name="QUEUE" physicalName="auto_check" />

<!--
     4.   (C)Converter    
-->
	<bean id="defaultMessageConverter" class="com.iteye.queue.DefaultMessageConverter" />

	
<!-- -------    :    ---->	
<!--
    1   JmsTemplate JMS  
   		   Spring   Template,   (A)ConnectionFactory (C)Converter。
-->
	<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
		<property name="connectionFactory">
			<!--  lets wrap in a pool to avoid creating a connection per send 
				       ,              
			-->
			<bean class="org.springframework.jms.connection.SingleConnectionFactory">
				<property name="targetConnectionFactory" ref="jmsConnectionFactory" />
			</bean>
		</property>
		<!-- custom MessageConverter 
			         
		-->
		<property name="messageConverter" ref="defaultMessageConverter" />
	</bean>
	
<!-- 2.Producer      ,  JmsTemplate    ,   JmsTemplate ( A、C) (B)Queue。-->
	<bean id="queueMessageProducer" class="com.iteye.queue.QueueMessageProducer">
		<property name="template" ref="jmsTemplate" />
		<property name="destination" ref="QUEUE" />
	</bean>	
<!-------    :   ----->
<!-- 1.     (MDP)  Spring MessageListenerAdapter,
	         POJO     ,  (C)Converter。
-->
	<bean id="queueConsumer" class="com.iteye.queue.QueueConsumer">
		<property name="interaction" ref="autoCheckInteraction" />
	</bean>
	
	<bean id="queueListener"
		class="org.springframework.jms.listener.adapter.MessageListenerAdapter">
		<!--           -->
		<constructor-arg ref="queueConsumer" />
		<!--           -->
		<property name="defaultListenerMethod" value="receive" />
		<!--       -->
		<property name="messageConverter" ref="defaultMessageConverter" />
	</bean>
<!-- 2. listenerContainer     MDP,   (A) connectionFactory, (B)Queue MDP。listener container,MDP       -->
	<bean id="queueListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
		<property name="connectionFactory" ref="jmsConnectionFactory" />
		<property name="destination" ref="QUEUE" />
		<property name="messageListener" ref="queueListener" />
	</bean>
</beans>

좋은 웹페이지 즐겨찾기