• 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) {
    //业务逻辑

    }

  • 相关阅读:
    ie浏览器下,get请求缓存问题
    grunt 单独压缩多个js和css文件【转】
    初次接触nodejs,请多指教。
    浮躁是一种流行病【转】
    php安装配置那些事(本文纯属个人记事与技术无关)
    读取年份数组中的所有周六周天
    C#窗体中读取修改xml文件
    Power BI brief introduction
    D365 CRM online trial application
    TalkingData Cocos2dx集成指南【最新】
  • 原文地址:https://www.cnblogs.com/coderdxj/p/7238873.html
Copyright © 2020-2023  润新知