1、增加pom.xml依赖

 <!--rabbitmq消息队列依赖架包-->
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>2.0.3.RELEASE</version>
</dependency> <!-- rabbitmq消息队列客户端依赖 -->
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.2.0</version>
</dependency>

2、在项目的resources目录下新增rabbitmq.properties配置文件

 #rabbitmq消息队列的属性配置文件properties
rabbitmq.study.host=192.168.56.101
rabbitmq.study.username=duanml
rabbitmq.study.password=123456
rabbitmq.study.port=5672
rabbitmq.study.vhost=studymq #Mail 消息队列的相关变量值
mail.exchange=mailExchange
mail.exchange.key=mail_queue_key #Phone 消息队列的相关变量值
phone.topic.key=phone.one
phone.topic.key.more=phone.one.more

3、增加spring的配置文件spring-rabbitmq.xml

 <?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:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <description>rabbitmq消息队列配置</description> <!--属性配置properties文件加载-->
<context:property-placeholder location="classpath:rabbitmq.properties"
ignore-unresolvable="true"></context:property-placeholder> <!-- rabbitmq消息队列连接配置 -->
<rabbit:connection-factory id="connectionFactory"
host="${rabbitmq.study.host}"
username="${rabbitmq.study.username}"
password="${rabbitmq.study.password}"
port="${rabbitmq.study.port}"
publisher-confirms="true"/> <rabbit:admin connection-factory="connectionFactory"/>
<!-- 消息对象json转换类 -->
<bean id="jsonMessageConverter" class="org.springframework.amqp.support.converter.Jackson2JsonMessageConverter"/> <!--申明一个消息队列Queue __> 用于发送Mail************************************Start************************-->
<!--
说明:
durable:是否持久化
exclusive: 仅创建者可以使用的私有队列,断开后自动删除
auto_delete: 当所有消费客户端连接断开后,是否自动删除队列
-->
<rabbit:queue id="mailQueue" name="mailQueue" durable="true" auto-delete="false" exclusive="false"/> <!--交换机定义
交换机的四种模式:
direct:转发消息到 routigKey 指定的队列。
topic:对 key 进行模式匹配,比如ab*可以传到到所有 ab* 的 queue。
headers:(这个还没有接触到)
fanout:转发消息到所有绑定队列,忽略 routigKey
交换器的属性:
持久性:如果启用,交换器将会在server重启前都有效。
自动删除:如果启用,那么交换器将会在其绑定的队列都被删除掉之后自动删除掉自身。
惰性:如果没有声明交换器,那么在执行到使用的时候会导致异常,并不会主动声明。
-->
<rabbit:direct-exchange id="mailExchange" name="mailExchange" durable="true" auto-delete="false">
<rabbit:bindings>
<rabbit:binding queue="mailQueue" key="mail_queue_key"/>
</rabbit:bindings>
</rabbit:direct-exchange> <!-- 消费者 -->
<bean id="mailConsumerListener" class="org.seckill.rabbitmqListener.mail.MailConsumerListener"></bean>
<!--消息确认后回调方法-->
<bean id="mailConfirmCallBackListener" class="org.seckill.rabbitmqListener.mail.MailConfirmCallBackListener"></bean>
<!--消息失败后Return回调-->
<bean id="mailFailedCallBackListener" class="org.seckill.rabbitmqListener.mail.MailFailedCallBackListener"></bean> <!-- spring template声明-->
<rabbit:template id="mailAMQPTemplate" exchange="mailExchange" mandatory="true"
message-converter="jsonMessageConverter"
confirm-callback="mailConfirmCallBackListener"
return-callback="mailFailedCallBackListener"
connection-factory="connectionFactory"/> <!-- 配置监听 -->
<rabbit:listener-container connection-factory="connectionFactory" acknowledge="manual">
<!--queues 监听队列,多个用逗号分隔 ref 监听器 -->
<rabbit:listener queues="mailQueue" ref="mailConsumerListener"></rabbit:listener>
</rabbit:listener-container>
<!--申明一个消息队列Queue __> 用于发送Mail************************************End************************--> <!--===============================================分割线==================================================--> <!--申明一个用于发送短信的消息队列__>用于发送短信Phone************************************Start************************-->
<!--
说明:
durable:是否持久化
exclusive: 仅创建者可以使用的私有队列,断开后自动删除
auto_delete: 当所有消费客户端连接断开后,是否自动删除队列
-->
<rabbit:queue id="PhoneQueueOne" name="PhoneQueueOne" durable="true" auto-delete="false" exclusive="false"/>
<rabbit:queue id="PhoneQueueTwo" name="PhoneQueueTwo" durable="true" auto-delete="false" exclusive="false"/> <!--交换机定义
交换机的四种模式:
direct:转发消息到 routigKey 指定的队列。
topic:对 key 进行模式匹配,比如ab*可以传到到所有 ab* 的 queue。
headers:(这个还没有接触到)
fanout:转发消息到所有绑定队列,忽略 routigKey
交换器的属性:
持久性:如果启用,交换器将会在server重启前都有效。
自动删除:如果启用,那么交换器将会在其绑定的队列都被删除掉之后自动删除掉自身。
惰性:如果没有声明交换器,那么在执行到使用的时候会导致异常,并不会主动声明。
-->
<rabbit:topic-exchange id="phoneExchange" name="phoneExchange" durable="true" auto-delete="false">
<rabbit:bindings>
<rabbit:binding queue="PhoneQueueOne" pattern="phone.*"></rabbit:binding>
<rabbit:binding queue="PhoneQueueTwo" pattern="phone.#"></rabbit:binding>
</rabbit:bindings>
</rabbit:topic-exchange> <!-- 消费者 -->
<bean id="phoneConsumerListener" class="org.seckill.rabbitmqListener.phone.PhoneConsumerListener"></bean>
<bean id="phoneConsumerListenerMore" class="org.seckill.rabbitmqListener.phone.PhoneConsumerListenerMore"></bean>
<!--消息确认后回调方法-->
<bean id="phoneConfirmCallBackListener" class="org.seckill.rabbitmqListener.phone.PhoneConfirmCallBackListener"></bean>
<!--消息失败后Return回调-->
<bean id="phoneFailedCallBackListener" class="org.seckill.rabbitmqListener.phone.PhoneFailedCallBackListener"></bean> <!-- spring template声明-->
<rabbit:template id="phoneAMQPTemplate" exchange="phoneExchange" mandatory="true"
message-converter="jsonMessageConverter"
confirm-callback="phoneConfirmCallBackListener"
return-callback="phoneFailedCallBackListener"
connection-factory="connectionFactory"/> <!-- 配置监听 -->
<rabbit:listener-container connection-factory="connectionFactory" acknowledge="manual">
<!--queues 监听队列,多个用逗号分隔 ref 监听器 -->
<rabbit:listener queues="PhoneQueueOne" ref="phoneConsumerListener"></rabbit:listener>
<rabbit:listener queues="PhoneQueueOne,PhoneQueueTwo" ref="phoneConsumerListenerMore"></rabbit:listener>
</rabbit:listener-container>
<!--申明一个用于发送短信的消息队列__>用于发送短信Phone************************************End************************--> </beans>

注意:

这里配置了两种常用的交换机:

direct-exchange                 对应  处理邮件的 Mail 的 消息队列
队列名称:mailQueue
操作Mail队列的 生产者使用的 mailAMQPTemplate
监听Mail队列的消费者 mailConsumerListener
确认消息处理成功的回调:mailConfirmCallBackListener
消息发送队列失败回调:mailFailedCallBackListener
topic-exchange           对应  处理短信发送 Phone 的消息队列
 队列名称:PhoneQueueOne、PhoneQueueTwo
  操作Phone队列的 生产者使用的 phoneAMQPTemplate
监听Phone队列的消费者 phoneConsumerListener、phoneConsumerListenerMore
确认消息处理成功的回调:phoneConfirmCallBackListener
消息发送队列失败回调:phoneFailedCallBackListener
4、编写实现的具体类
消息接口类:MQProducer.java
 package org.seckill.utils.rabbitmq;

 import org.springframework.amqp.core.MessagePostProcessor;

 /**
* <p>Title: org.seckill.utils.rabbitmq</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 11:49
* Description: No Description
*/
public interface MQProducer { /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* @param message
*/
public void sendDataToRabbitMQ(Object message); /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(Object message, MessagePostProcessor messagePostProcessor); /**
* 发送消息到指定的队列中
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String routingKey, Object message); /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String routingKey, Object message, MessagePostProcessor messagePostProcessor); /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* @param exchange
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message); /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* @param exchange
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor);
}

Mail生产者的实现类:MailProducerImpl.java

 package org.seckill.utils.rabbitmq.Impl;

 import org.seckill.utils.rabbitmq.MQProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; /**
* <p>Title: org.seckill.utils.rabbitmq.Impl</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 11:50
* Description: 消息生产者的操作类
*/
@Component
public class MailProducerImpl implements MQProducer { private static final Logger logger = LoggerFactory.getLogger(MailProducerImpl.class); @Autowired
private AmqpTemplate mailAMQPTemplate; /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param message
*/
public void sendDataToRabbitMQ(Object message) {
try {
mailAMQPTemplate.convertAndSend(message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(Object message, MessagePostProcessor messagePostProcessor) {
try {
mailAMQPTemplate.convertAndSend(message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* 发送消息到指定的队列中
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String routingKey, Object message) {
try {
mailAMQPTemplate.convertAndSend(routingKey,message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String routingKey, Object message, MessagePostProcessor messagePostProcessor) {
try {
mailAMQPTemplate.convertAndSend(routingKey,message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param exchange
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message) {
try {
mailAMQPTemplate.convertAndSend(exchange,routingKey,message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param exchange
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) {
try {
mailAMQPTemplate.convertAndSend(exchange,routingKey,message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
}
}

短信发送队列的生产者实现类:PhoneProducerImpl.java

 package org.seckill.utils.rabbitmq.Impl;

 import org.seckill.utils.rabbitmq.MQProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.AmqpException;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.MessagePostProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; /**
* <p>Title: org.seckill.utils.rabbitmq.Impl</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 11:50
* Description: 消息生产者的操作类
*/
@Component
public class PhoneProducerImpl implements MQProducer { private static final Logger logger = LoggerFactory.getLogger(PhoneProducerImpl.class); @Autowired
private AmqpTemplate phoneAMQPTemplate; /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param message
*/
public void sendDataToRabbitMQ(Object message) {
try {
phoneAMQPTemplate.convertAndSend(message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a default routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(Object message, MessagePostProcessor messagePostProcessor) {
try {
phoneAMQPTemplate.convertAndSend(message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* 发送消息到指定的队列中
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String routingKey, Object message) {
try {
phoneAMQPTemplate.convertAndSend(routingKey,message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a default exchange with a specific routing key
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String routingKey, Object message, MessagePostProcessor messagePostProcessor) {
try {
phoneAMQPTemplate.convertAndSend(routingKey,message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param exchange
* @param routingKey
* @param message
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message) {
try {
phoneAMQPTemplate.convertAndSend(exchange,routingKey,message);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
} /**
* Convert a Java object to an Amqp Message and send it to a specific exchange with a specific routing key.
* 由于配置了JSON转换,这里是将Java对象转换成JSON字符串的形式。
* @param exchange
* @param routingKey
* @param message
* @param messagePostProcessor
*/
public void sendDataToRabbitMQ(String exchange, String routingKey, Object message, MessagePostProcessor messagePostProcessor) {
try {
phoneAMQPTemplate.convertAndSend(exchange,routingKey,message,messagePostProcessor);
} catch (AmqpException e) {
logger.error(e.getMessage(),e);
}
}
}

以下为:消费者相关的实现类:=======================================================================

Mail消息消费者实现类 MailConsumerListener.java

 package org.seckill.rabbitmqListener.mail;

 import com.rabbitmq.client.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; /**
* <p>Title: org.seckill.rabbitmqListener</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 17:55
* Description: 消费方实现类
*/
public class MailConsumerListener implements ChannelAwareMessageListener { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public void onMessage(Message message, Channel channel) throws Exception {
try{
logger.info("mail------->consumer--:"+message.getMessageProperties()+":"+new String(message.getBody()));
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
}catch(Exception e){
logger.error(e.getMessage(),e);
channel.basicNack(message.getMessageProperties().getDeliveryTag(), false,false);
}
}
}

Mail消息确认实现类:MailConfirmCallBackListener.java

 package org.seckill.rabbitmqListener.mail;

 import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
import org.springframework.amqp.rabbit.support.CorrelationData; /**
* <p>Title: org.seckill.rabbitmqListener</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 17:59
* Description: 确认后回调方法
*/
public class MailConfirmCallBackListener implements ConfirmCallback { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public void confirm(CorrelationData correlationData, boolean ack, String cause) {
logger.info("mail----------->confirm--:correlationData:" + correlationData + ",ack:" + ack + ",cause:" + cause);
}
}

Mail消息发送失败回调实现类:MailFailedCallBackListener.java

 package org.seckill.rabbitmqListener.mail;

 import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnCallback; /**
* <p>Title: org.seckill.rabbitmqListener</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 18:03
* Description: 失败后return回调
*/
public class MailFailedCallBackListener implements ReturnCallback { private final Logger logger = LoggerFactory.getLogger(this.getClass()); public void returnedMessage(Message message, int replyCode,
String replyText, String exchange,
String routingKey) { logger.info("Mail------------->return--message:" +
new String(message.getBody()) +
",replyCode:" + replyCode + ",replyText:" + replyText +
",exchange:" + exchange + ",routingKey:" + routingKey);
}
}

5、Controller层的测试类:

RabbitmqController.java

 package org.seckill.web;

 import org.seckill.dto.SeckillResult;
import org.seckill.entity.Seckill;
import org.seckill.utils.rabbitmq.Impl.MailProducerImpl;
import org.seckill.utils.rabbitmq.Impl.PhoneProducerImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; import java.util.Date;
import java.util.HashMap;
import java.util.Map; /**
* <p>Title: org.seckill.web</p>
* <p>Company:东软集团(neusoft)</p>
* <p>Copyright:Copyright(c)2018</p>
* User: 段美林
* Date: 2018/5/30 17:33
* Description: 消息队列测试
*/
@Controller
@RequestMapping("/rabbitmq")
public class RabbitmqController { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @Value("${mail.exchange.key}")
private String queue_key; @Value("${phone.topic.key.more}")
private String phone_key_more; @Value("${phone.topic.key}")
private String phone_key; @Autowired
private MailProducerImpl mailProducer; @Autowired
private PhoneProducerImpl phoneProducer; /**
* @Description: 消息队列
* @Author:
* @CreateTime:
*/
@ResponseBody
@RequestMapping("/sendMailQueue")
public SeckillResult<Long> testMailQueue() {
SeckillResult<Long> result = null;
Date now = new Date();
try {
Seckill seckill = new Seckill();
seckill.setSeckillId(19339387);
seckill.setName("duanml");
mailProducer.sendDataToRabbitMQ(queue_key, seckill);
result = new SeckillResult<Long>(true, now.getTime());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return result;
} /**
* @Description: 消息队列
* @Author:
* @CreateTime:
*/
@ResponseBody
@RequestMapping("/sendPhoneQueue")
public SeckillResult<Long> testPhoneQueue() {
SeckillResult<Long> result = null;
Date now = new Date();
try {
Seckill seckill = new Seckill(); for (int i = 0; i < 10 ; i++) {
seckill.setSeckillId(1922339387+i);
seckill.setName("caijuan" + i);
phoneProducer.sendDataToRabbitMQ(phone_key, seckill);
}
seckill.setSeckillId(1240943092);
seckill.setName("yinhaiyan");
phoneProducer.sendDataToRabbitMQ(phone_key_more, seckill); result = new SeckillResult<Long>(true, now.getTime());
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
return result;
} }

运行项目

测试地址输入:测试Mail

测试phone


rabbitmq 和Spring 集成 实现(一)的更多相关文章

  1. 消息中间件系列四:RabbitMQ与Spring集成

    一.RabbitMQ与Spring集成  准备工作: 分别新建名为RabbitMQSpringProducer和RabbitMQSpringConsumer的maven web工程 在pom.xml文 ...

  2. RabbitMQ与spring集成,配置完整的生产者和消费者

    RabbitMQ与AMQP协议详解可以看看这个 http://www.cnblogs.com/frankyou/p/5283539.html 下面是rabbitMQ和spring集成的配置,我配置了二 ...

  3. RabbitMQ入门教程(十六):RabbitMQ与Spring集成

    原文:RabbitMQ入门教程(十六):RabbitMQ与Spring集成 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https: ...

  4. RabbitMQ与Spring集成

    RabbitMQ服务端安装: https://blog.csdn.net/hzw19920329/article/details/53156015 与Spring集成 https://www.cnbl ...

  5. 消息队列RabbitMQ与Spring集成

    1.RabbitMQ简介 RabbitMQ是流行的开源消息队列系统,用erlang语言开发.RabbitMQ是AMQP(高级消息队列协议)的标准实现. 官网:http://www.rabbitmq.c ...

  6. RabbitMQ ——与Spring集成及exchange的direct、topic方式实现和简单队列实现

    程序整体结构 Maven依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http: ...

  7. RabbitMQ与Spring集成配置

    1.引入相关jar包 //RabbitMQ compile group: 'org.springframework.amqp', name: 'spring-rabbit', version: '1. ...

  8. RabbitMQ-从基础到实战(6)— 与Spring集成

    0.目录 RabbitMQ-从基础到实战(1)- Hello RabbitMQ RabbitMQ-从基础到实战(2)- 防止消息丢失 RabbitMQ-从基础到实战(3)- 消息的交换(上) Rabb ...

  9. rabbitMQ第五篇:Spring集成RabbitMQ

    前面几篇讲解了如何使用rabbitMq,这一篇主要讲解spring集成rabbitmq. 首先引入配置文件org.springframework.amqp,如下 <dependency> ...

随机推荐

  1. 【跟着stackoverflow学Pandas】 -Get list from pandas DataFrame column headers - Pandas 获取列名

    最近做一个系列博客,跟着stackoverflow学Pandas. 以 pandas作为关键词,在stackoverflow中进行搜索,随后安照 votes 数目进行排序: https://stack ...

  2. jquery.cycle.js

    jquery.cycle.js简单用法实例 样式: a{text-decoration: none;} *{margin:0; padding:0;} /*容器设置*/ .player { width ...

  3. python将字符转换为字典

    参考文章Python 如何将字符串转为字典 注意: 使用json的时候一定要注意是loads而不是load 即:user_dict = json.loads(user_info) 注意: 用eval( ...

  4. Map集合统计字母次数

    Map集合练习:"asfefxAAcf34vrfdfse2-2asd--wdd"获取该字符串中,每一个字母出现的次数要求打印的结果是:a(2)c(1)...;思路:对结果分析发现, ...

  5. http的报文结构和状态码的含义

    HTTP响应报文解剖 响应报文结构 HTTP的响应报文也由三部分组成(响应行+响应头+响应体): 以下是一个实际的HTTP响应报文: ①报文协议及版本: ②状态码及状态描述: ③响应报文头,也是由多个 ...

  6. scrapy多线程文件下载

    在爬取数据时有时候有些文件数据需要爬取下载下来使用多线程下载可以让程序跑的更快点. scrapy中有个扩展可以使用扩展模块来实现下载. 在自己的spider中加入 custom_settings cl ...

  7. MacOS 如何截屏

    在Mac OS X下有很强大的截屏功能,它不仅仅是对屏幕的全屏COPY,而是包括很多细节在里面,就从这点来看,已经比过所有版本的Windows了. 下面我来向大家详细介绍一下: 对全屏的截图我们可以通 ...

  8. Mac下忘记mysql密码怎么办

    Mac本地安装了数据库,忘记数据库密码的情况下,可以按照以下步骤进行修改密码 step1: 关闭mysql服务: 苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服 ...

  9. sysstat工具

    sysstat工具可以监控系统的IO,CPU,SWAP,LOAD,NETWORK,DISK 安装后,系统会生成定时任务脚本 路径:/etc/cron.d/sysstat 内容: # Run syste ...

  10. PTHREAD的WINDOWS开发包

    PTHREAD的WINDOWS开发包 网站地址是http://sourceware.org/pthreads-win32/