码迷,mamicode.com
首页 > 编程语言 > 详细

spring 整合rabbitMQ

时间:2017-07-26 12:33:02      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:manage   delete   message   bit   rabbit   als   connect   处理   bean   

<!-- 配置邮件消息队列监听 -->
<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) {
//业务逻辑

 

}

spring 整合rabbitMQ

标签:manage   delete   message   bit   rabbit   als   connect   处理   bean   

原文地址:http://www.cnblogs.com/coderdxj/p/7238873.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!