applicationContext-mq.xml 7.24 KB


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:rabbit="http://www.springframework.org/schema/rabbit"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context-4.2.xsd
                       http://www.springframework.org/schema/rabbit
                       http://www.springframework.org/schema/rabbit/spring-rabbit-1.0.xsd">

    <!-- 连接服务配置 -->
    <bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
        <property name="username" value="${search.mq.username}"/>
        <property name="password" value="${search.mq.password}"/>
        <property name="addresses" value="${search.mq.server}:${search.mq.port}"/>
        <property name="channelCacheSize" value="60"/>
        <property name="virtualHost" value="${search.mq.virtualHost}"/>
    </bean>

    <rabbit:admin connection-factory="connectionFactory" />

    <!-- queue 队列声明 -->
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_style" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_brand" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_size" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_storage" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_product" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productcolor" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productprice" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_goods" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_goodsimages" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productstandardrelation" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productstylerelation" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productsort" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_standard" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productindex" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_activityproduct" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productsearch" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productactivitieslink" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_parametermake" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_searchaction" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productkeywords" />
    <rabbit:queue durable="true" exclusive="false" name="data_update_channel_productpooldetail" />

    <rabbit:template exchange="${search.mq.exchange}" id="amqpTemplate"
                     connection-factory="connectionFactory" message-converter="jsonMessageConverter" />
    <bean id="jsonMessageConverter" class="com.yoho.search.consumer.common.FastJsonMessageConverter"></bean>

    <bean id="taskExecutor"
          class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
        <property name="corePoolSize" value="100" />
        <property name="maxPoolSize" value="200" />
        <property name="keepAliveSeconds" value="30000" />
        <property name="queueCapacity" value="3000" />
        <property name="WaitForTasksToCompleteOnShutdown" value="false" />
    </bean>

    <bean id="productMqListener0" class="com.yoho.search.consumer.index.increment.ProductMqListener"></bean>
    <bean id="productMqListener1" class="com.yoho.search.consumer.index.increment.ProductMqListener"></bean>
    <bean id="productMqListener2" class="com.yoho.search.consumer.index.increment.ProductMqListener"></bean>
    <bean id="productMqListener3" class="com.yoho.search.consumer.index.increment.ProductMqListener"></bean>
    <bean id="productMqListener4" class="com.yoho.search.consumer.index.increment.ProductMqListener"></bean>

    <rabbit:listener-container connection-factory="connectionFactory" task-executor="taskExecutor"  concurrency="1">
        <rabbit:listener queue-names="data_update_channel_style" ref="styleMqListener" />
        <rabbit:listener queue-names="data_update_channel_brand" ref="brandMqListener" />
        <rabbit:listener queue-names="data_update_channel_size" ref="sizeMqListener" />
        <rabbit:listener queue-names="data_update_channel_storage" ref="storageMqListener" />
        <rabbit:listener queue-names="data_update_channel_productcolor" ref="productColorMqListener" />
        <rabbit:listener queue-names="data_update_channel_productprice" ref="productPriceMqListener" />
        <rabbit:listener queue-names="data_update_channel_goods" ref="goodsMqListener" />
        <rabbit:listener queue-names="data_update_channel_goodsimages" ref="goodsImagesMqListener" />
        <rabbit:listener queue-names="data_update_channel_productstandardrelation" ref="productStandardRelationMqListener" />
        <rabbit:listener queue-names="data_update_channel_productstylerelation" ref="productStyleRelationMqListener" />
        <rabbit:listener queue-names="data_update_channel_productsort" ref="productSortMqListener" />
        <rabbit:listener queue-names="data_update_channel_standard" ref="standardMqListener" />
        <rabbit:listener queue-names="data_update_channel_productindex" ref="productIndexMqListener" />
        <rabbit:listener queue-names="data_update_channel_activityproduct" ref="activityProductMqListener" />
        <rabbit:listener queue-names="data_update_channel_productsearch" ref="productSearchMqListener" />
        <rabbit:listener queue-names="data_update_channel_productactivitieslink" ref="productActivitiesLinkMqListener" />
        <rabbit:listener queue-names="data_update_channel_parametermake" ref="parameterMakeMqListener" />
        <rabbit:listener queue-names="data_update_channel_searchaction" ref="searchActionMqListener" />
        <rabbit:listener queue-names="data_update_channel_productkeywords" ref="productKeywordsMqListener" />
        <rabbit:listener queue-names="data_update_channel_productpooldetail" ref="productPoolDetailMqListener" />

        <rabbit:listener queue-names="data_update_channel_product" ref="productMqListener" />
        <rabbit:listener queue-names="data_update_channel_product_0" ref="productMqListener0" />
        <rabbit:listener queue-names="data_update_channel_product_1" ref="productMqListener1" />
        <rabbit:listener queue-names="data_update_channel_product_2" ref="productMqListener2" />
        <rabbit:listener queue-names="data_update_channel_product_3" ref="productMqListener3" />
        <rabbit:listener queue-names="data_update_channel_product_4" ref="productMqListener4" />

    </rabbit:listener-container>
</beans>