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. 最新ICE源码编译安装

    发现ICE3.7版本在编译安装时比之前的版本省事了很多,少了很多杂七杂八的依赖库:估计是被grpc火热情景给逼的? Compiling [amd64-shared] src/Ice/Collocate ...

  2. BZOJ3123: [Sdoi2013]森林(启发式合并&主席树)

    3123: [Sdoi2013]森林 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 4813  Solved: 1420[Submit][Status ...

  3. java利用freemarker导出world

    一.简单导出(不含循环导出) 1.新建一个word文件.如下图: 2.使用word将文件另存为xml的格式 3.编辑xml文件内容,将'用户名'替换成-> ${username}.'简介'替换成 ...

  4. java spring boot 出现 java.lang.UnsatisfiedLinkError

    java.lang.UnsatisfiedLinkError: E:\ruanjian\jdk\bin\tcnative-1.dll: Can't load IA 32-bit .dll on a A ...

  5. StreamSets 部署 Pipelines 到 SDC Edge

    可以使用如下方法: 下载edge 运行包并包含pipeline定义文件. 直接发布到edge 设备. 在data colelctor 机器配置并配置了edge server 地址(主要需要网络可访问) ...

  6. web应用中的Filter过滤器之基础概述

    1 过滤器概述 当web容器接收到对一个资源的请求时,它将判断是否有过滤器与这个资源相关联,如果有,那么容器将把这个请求交给过滤器进行处理.在过滤器中,你可以改变请求的内容或者重新设置请求的报头信息, ...

  7. 微信小程序设置底部导航栏目方法

    微信小程序底部想要有一个漂亮的导航栏目,不知道怎么制作,于是百度找到了本篇文章,分享给大家. 好了 小程序的头部标题 设置好了,我们来说说底部导航栏是如何实现的. 我们先来看个效果图 这里,我们添加了 ...

  8. 关于centos7.5部署oelinker_php版本的问题点汇总

    1.下载开源版本https://github.com/eolinker/eoLinker-AMS-Lite-For-PHP到本地,将release文件夹内容copy到apache的/var/www/h ...

  9. pycharm -- 小技巧1 (显示文件的代码结构以及错误提示)

    背景介绍 今天上午,在调用同事昨天给的算法程序时出了点问题,于是请同事来我这边一起调代码.大致场景描述如下: 我:B神,你昨天下班前给我的那个算法程序我这边调用的时候出现错误啦,请你过来看下呗. 同事 ...

  10. 使用Java配置SpringMVC

    在此之前,一直使用的是XML的方式配置SpringMVC,现在为了适应Servlert3.0以及JavaConfig的Spring配置方式,在这里记录一下使用Java代码配置SpringMVC.首先, ...