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

 

}

上一篇:3.matplotlib介绍


下一篇:关于canon mx538无线连接的问题