• spring 整合rabbitMQ


    <!-- 配置邮件消息队列监听 -->
    <bean id="maillistener" class="cn.xdf.wlyy.listener.Maillistener"
    name="maillistener">
    <property name="mailManager" ref="mailManager"></property>
    <property name="msgLogService" ref="msgLogService"></property>
    </bean>
    <!-- 配置短信消息队列监听 -->
    <bean id="smslistener" class="cn.xdf.wlyy.listener.SmsListener"
    name="smslistener">
    <property name="deptService" ref="deptService"></property>
    <property name="msgLogService" ref="msgLogService"></property>
    </bean>

    <!-- 定义邮件队列 -->
    <rabbit:queue id="mail_queue" durable="true" auto-delete="false"
    exclusive="false" name="mail_queue" />
    <!-- 定义短信队列 -->
    <rabbit:queue id="sms_queue" durable="true" auto-delete="false"
    exclusive="false" name="sms_queue" />
    <!-- 定义mq 地址,端口,用户, 密码 -->
    <rabbit:connection-factory id="connectionFactory"
    host="${mq.host}" port="${mq.port}" username="${mq.username}"
    password="${mq.password}" />
    <rabbit:admin connection-factory="connectionFactory" id="myadmin" />
    <!-- 定义rabbit template发送/接受消息 -->
    <rabbit:template id="amqpTemplate" connection-factory="connectionFactory"></rabbit:template>
    <!-- 监听邮件队列 -->
    <rabbit:listener-container
    connection-factory="connectionFactory" acknowledge="auto">
    <rabbit:listener queues="mail_queue" ref="maillistener" />
    </rabbit:listener-container>
    <!-- 监听短信队列 -->
    <rabbit:listener-container
    connection-factory="connectionFactory" acknowledge="auto">
    <rabbit:listener queues="sms_queue" ref="smslistener" />
    </rabbit:listener-container>

    //监听方式实时处理消息

    public class Maillistener implements MessageListener {

    @Override
    public void onMessage(Message message) {
    //业务逻辑

    }

  • 相关阅读:
    顺序查找
    折半查找
    KMP
    php长时间的脚本,报502
    AcWing 27. 数值的整数次方
    acwing 25. 剪绳子
    Best Cow Line <挑战程序设计竞赛> 习题 poj 3617
    acwing 23. 矩阵中的路径
    AcWing 34. 链表中环的入口结点
    AcWing 33. 链表中倒数第k个节点
  • 原文地址:https://www.cnblogs.com/coderdxj/p/7238873.html
Copyright © 2020-2023  润新知