spring-common-rabbitmq.xml 2.3 KB
<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" xmlns:util="http://www.springframework.org/schema/util"
       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 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


    <bean id="simpleMessageConverter-common" class="org.springframework.amqp.support.converter.SimpleMessageConverter"/>


    <rabbit:connection-factory id="rabbitmq-connectionFactory-qq" addresses="${rabbit_common_qq:127.0.0.1:5672}"
                               username="${rabbit_common_qq_user:yoho}" password="${rabbit_common_qq_password:yoho}"
                               virtual-host="${rabbit_vhost:yoho}"/>
    <rabbit:admin id="rabbitAdmin-qq" connection-factory="rabbitmq-connectionFactory-qq"/>


    <rabbit:connection-factory id="rabbitmq-connectionFactory-aws" addresses="${rabbit_common_aws:127.0.0.1:5672}"
                               username="${rabbit_common_aws_user:yoho}" password="${rabbit_common_aws_password:yoho}"
                               virtual-host="${rabbit_vhost:yoho}"/>
    <rabbit:admin id="rabbitAdmin-aws" connection-factory="rabbitmq-connectionFactory-aws"/>


    <!--接收消息 -->
    <bean id="commonConsumerFactory" class="com.yoho.unions.message.CommonConsumerFactory">
        <!--这边admin的顺序和connectionFactory的顺序要一一对应-->
        <constructor-arg name="admins">
            <list>
                <ref bean="rabbitAdmin-qq"/>
                <ref bean="rabbitAdmin-aws"/>
            </list>
        </constructor-arg>
        <constructor-arg name="connectionFactorys">
            <list>
                <ref bean="rabbitmq-connectionFactory-qq"/>
                <ref bean="rabbitmq-connectionFactory-aws"/>
            </list>
        </constructor-arg>
        <constructor-arg name="context" value="${web.context:default}"/>
        <constructor-arg name="simpleMessageConverter" ref="simpleMessageConverter-common"/>
    </bean>


</beans>