spring-common-rabbitmq.xml
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="simpleMessageConverter-common" class="org.springframework.amqp.support.converter.SimpleMessageConverter"/>
<rabbit:connection-factory id="rabbitmq-connectionFactory-common" addresses="${rabbit_common:127.0.0.1:5672}"
requested-heartbeat="10" username="${rabbit_common_user:yoho}" password="${rabbit_common_password:yoho}"
virtual-host="${rabbit_vhost:yoho}"/>
<rabbit:admin id="rabbitAdmin-common" connection-factory="rabbitmq-connectionFactory-common"/>
<rabbit:template id="amqpTemplate-common" connection-factory="rabbitmq-connectionFactory-common"
message-converter="simpleMessageConverter-common"/>
<!--发送消息
<bean id="producerTemplateCommon" class="com.yohobuy.platform.common.message.YhProducerTemplateCommon">
<property name="amqpTemplate" ref="amqpTemplate-common"/>
</bean>-->
<!--接收消息 -->
<bean id="productConsumerFactory" class="com.yohobuy.platform.common.message.MessageConsumerFactory">
<!--这边admin的顺序和connectionFactory的顺序要一一对应-->
<constructor-arg name="admins">
<list>
<ref bean="rabbitAdmin-common"/>
</list>
</constructor-arg>
<constructor-arg name="connectionFactorys">
<list>
<ref bean="rabbitmq-connectionFactory-common"/>
</list>
</constructor-arg>
<constructor-arg name="context" value="${web.context:default}"/>
<constructor-arg name="simpleMessageConverter" ref="simpleMessageConverter-common"/>
</bean>
</beans>