pom.xml加

<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>4.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-amqp</artifactId>
<version>1.7.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
<version>1.7.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>http-client</artifactId>
<version>1.1.1.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<!--公司的封装rabbitmq工具-->
 <dependency>
<groupId>com.yonyou.f4</groupId>
<artifactId>common</artifactId>
<version>1.2.2</version>
</dependency>
 

2.War打包时 有些包不会打进去,统一放在了D:\tools\f4\apache-tomcat-8.0.36\shared\lib下,如果pom新dependcy包不起作用检查下是否在不打包的列表中,如是手工复制到tomcat-8.0.36\shared\lib下,比如在使用rabbitmq时用到spring-rabbit.jar 和spring-retry-1.2.0.RELEASE.jar需复制过去,不然启动时报错

3.spring xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit.xsd"> <!-- <context:component-scan base-package="com.yonyou.dms.web.controller" /> -->
<!-- <bean -->
<!-- class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> -->
<!-- <property name="viewResolvers"> -->
<!-- <list> -->
<!-- <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> -->
<!-- <bean -->
<!-- class="org.springframework.web.servlet.view.InternalResourceViewResolver"> -->
<!-- <property name="prefix" value="/WEB-INF/jsp/" /> -->
<!-- <property name="suffix" value=".jsp" /> -->
<!-- </bean> -->
<!-- </list> -->
<!-- </property> -->
<!-- <property name="defaultViews"> -->
<!-- <list> -->
<!-- JSON View -->
<!-- <bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" /> --> <!-- XML View -->
<!-- <bean class="org.springframework.web.servlet.view.xml.MarshallingView"> -->
<!-- <property name="marshaller"> -->
<!-- <bean class="org.springframework.oxm.xstream.XStreamMarshaller" /> -->
<!-- </property> -->
<!-- </bean> -->
<!-- </list> -->
<!-- </property> -->
<!-- </bean> --> <!-- 换成如下写法 -->
<!-- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" -->
<!-- p:messageConverters-ref="messageConverters"> -->
<!-- </bean> -->
<!-- <util:list id="messageConverters"> -->
<!-- <bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" /> -->
<!-- <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" /> -->
<!-- <bean class="org.springframework.http.converter.StringHttpMessageConverter" > -->
<!-- <property name="supportedMediaTypes"> -->
<!-- <list> -->
<!-- <value>text/plain;charset=UTF-8</value> -->
<!-- <value>text/html;charset=UTF-8</value> -->
<!-- </list> -->
<!-- </property> -->
<!-- </bean> -->
<!-- <bean class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" /> -->
<!-- <bean class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter" -->
<!-- p:marshaller-ref="xmlMarshaller" p:unmarshaller-ref="xmlMarshaller"> -->
<!-- </bean> -->
<!-- <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> -->
<!-- <property name="supportedMediaTypes"> -->
<!-- <list> -->
<!-- <value>application/json; charset=UTF-8</value> -->
<!-- <value>application/x-www-form-urlencoded; charset=UTF-8</value> -->
<!-- <value>multipart/form-data; charset=UTF-8</value> -->
<!-- </list> -->
<!-- </property> -->
<!-- <property name="objectMapper"> -->
<!-- <bean class="com.yonyou.dms.framework.filter.XssObjectMappper" id="XssObjectMappper"/> -->
<!-- </property> -->
<!-- </bean> -->
<!-- </util:list> -->
<!-- <bean id="xmlMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller"> -->
<!-- <property name="streamDriver"> -->
<!-- <bean class="com.thoughtworks.xstream.io.xml.StaxDriver" /> -->
<!-- </property> -->
<!-- </bean> --> <beans profile="source">
<mvc:annotation-driven validator="validator">
<mvc:message-converters>
<bean class="org.springframework.http.converter.BufferedImageHttpMessageConverter" />
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" id="MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json; charset=UTF-8</value>
<value>application/x-www-form-urlencoded; charset=UTF-8</value>
<value>multipart/form-data; charset=UTF-8</value>
</list>
</property>
<property name="objectMapper">
<bean class="com.yonyou.dmsgms.framework.filter.XssObjectMappper" id="XssObjectMappper"/>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven> <!-- upload settings -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5242880"></property>
<property name="resolveLazily" value="true"/>
</bean> <!-- 国际化配置 -->
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver" >
<property name="cookieName" value="language"></property>
</bean> <bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages/webValidate</value>
<value>messages/manageValidate</value>
<value>messages/customerValidate</value>
<value>messages/partValidate</value>
<value>messages/repairValidate</value>
<value>messages/vehicleValidate</value>
<value>messages/retailValidate</value>
<value>messages/commonASValidate</value>
<value>messages/commonValidate</value>
</list>
</property>
</bean> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
<!-- 这里配置将使用上面国际化配置的messageSource -->
<property name="validationMessageSource" ref="messageSource"/>
</bean> <!-- 权限拦截 -->
<bean id="aclInterceptor" class="com.yonyou.f4.common.acl.interceptor.AclInterceptor">
<property name="aclUserParamName" value="${f4.mvc.aclUser.key}"></property>
<property name="anonymUID" value="${f4.mvc.aclUser.anonymUID}"></property>
<property name="tenantIdParamName" value="${f4.mvc.tenant.key}"></property>
<property name="aclManager" ref="aclManager"></property>
<property name="preRes" ref="prepareResouce"></property>
<property name="errorPage" value="error.jsp"></property>
<!-- <property name="exclude"> -->
<!-- <value><![CDATA[.*\.(js|css|jpg|htm|html|woff|bmp|jpeg|png|gif){1}]]></value> -->
<!-- </property>不做权限验证 -->
</bean>
<bean id="prepareResouce" class="com.yonyou.dmsgms.framework.interceptors.acl.DmsPrepareResourceImpl">
</bean>
<bean id="aclManager" class="com.yonyou.f4.common.acl.impl.AclManagerImpl">
<property name="cacheExpireTime" value="30"></property><!-- 单位分钟 -->
<!-- <property name="redisFactory" ref="jedisFactory"></property> -->
<property name="provider" ref="aclDataProvider"></property>
</bean>
<bean id="aclDataProvider" class="com.yonyou.dmsgms.framework.interceptors.acl.AclDmsDataProvider"></bean> <!-- DMS 系统拦截器 -->
<bean id="dmsFrameworkInterceptor" class="com.yonyou.dmsgms.framework.interceptors.DMSFrameworkInterceptor"/> <!-- mvc 配置 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<ref bean="dmsFrameworkInterceptor"/>
</mvc:interceptor>
<!-- <mvc:interceptor> -->
<!-- <mvc:mapping path="/**"/> -->
<!-- <ref bean="aclInterceptor"/> -->
<!-- </mvc:interceptor> -->
</mvc:interceptors> <!-- 权限拦截 --> <!-- <bean id="viewResolver" -->
<!-- class="org.springframework.web.servlet.view.UrlBasedViewResolver"> -->
<!-- <property name="viewClass" -->
<!-- value="org.springframework.web.servlet.view.JstlView" /> -->
<!-- <property name="prefix" value="/html/error/" /> -->
<!-- <property name="suffix" value=".html" /> -->
<!-- </bean> --> <bean id="jsonFactory" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
<property name="failOnEmptyBeans" value="false"/>
<property name="indentOutput" value="true"/>
<property name="dateFormat">
<bean class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy-MM-dd HH:mm:ss"/>
</bean>
</property>
<property name="featuresToDisable">
<array>
<value type="com.fasterxml.jackson.databind.DeserializationFeature">FAIL_ON_UNKNOWN_PROPERTIES</value>
</array>
</property>
</bean> <bean class="com.yonyou.f4.common.msg.impl.TopicProducerImpl" init-method="init">
<property name="connectionFactory" ref="rabbitmq_cf"/>
<property name="objectMapper" ref="jsonFactory"/>
<property name="topics">
<set>
<value>ms01.t1</value>
<value>ms01.t2</value>
</set>
</property>
</bean>
<bean class="com.yonyou.f4.common.msg.impl.TopicConsumerImpl" init-method="init" destroy-method="destroy">
<property name="connectionFactory" ref="rabbitmq_cf"/>
<property name="objectMapper" ref="jsonFactory"/>
<property name="maxThreads" value="10"/>
<property name="queues">
<map>
<entry key="ms01.c1">
<map>
<entry key="ms01.t1" value="ms01.user.login"/>
</map>
</entry>
</map>
</property>
<property name="handlers">
<map>
<entry key="ms01.user.login">
<bean class="com.yonyou.dms.web.controller.basedata.MsgHandler"/>
</entry>
<entry key="default">
<bean class="com.yonyou.dms.web.controller.basedata.MsgHandler"/>
</entry>
</map>
</property>
</bean> <rabbit:connection-factory id="rabbitmq_cf" host="10.180.6.182" username="admin" password="admin123" port="5672" virtual-host="gclub"/> </beans>
</beans>

spring rabbitmq集成的更多相关文章

  1. RabbitMQ(3) Spring boot集成RabbitMQ

    springboot集成RabbitMQ非常简单,如果只是简单的使用配置非常少,springboot提供了spring-boot-starter-amqp项目对消息各种支持. 资源代码:练习用的代码. ...

  2. Spring boot集成RabbitMQ(山东数漫江湖)

    RabbitMQ简介 RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统 MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出 ...

  3. spring boot Rabbitmq集成,延时消息队列实现

    本篇主要记录Spring boot 集成Rabbitmq,分为两部分, 第一部分为创建普通消息队列, 第二部分为延时消息队列实现: spring boot提供对mq消息队列支持amqp相关包,引入即可 ...

  4. Spring Boot 集成 RabbitMQ 实战

    Spring Boot 集成 RabbitMQ 实战 特别说明: 本文主要参考了程序员 DD 的博客文章<Spring Boot中使用RabbitMQ>,在此向原作者表示感谢. Mac 上 ...

  5. spring boot集成RabbitMQ

    原文:https://www.jianshu.com/p/e1258c004314 RabbitMQ作为AMQP的代表性产品,在项目中大量使用.结合现在主流的spring boot,极大简化了开发过程 ...

  6. Spring Boot 集成RabbitMQ

    在Spring Boot中整合RabbitMQ是非常容易的,通过在Spring Boot应用中整合RabbitMQ,实现一个简单的发送.接收消息的例子. 首先需要启动RabbitMQ服务,并且add一 ...

  7. 85. Spring Boot集成RabbitMQ【从零开始学Spring Boot】

    这一节我们介绍下Spring Boot整合RabbitMQ,对于RabbitMQ这里不过多的介绍,大家可以参考网络上的资源进行安装配置,本节重点是告诉大家如何在Spring Boot中使用Rabbit ...

  8. spring boot 集成 rabbitmq 指南

    先决条件 rabbitmq server 安装参考 一个添加了 web 依赖的 spring boot 项目 我的版本是 2.5.2 添加 maven 依赖 <dependency> &l ...

  9. Spring boot集成Rabbit MQ使用初体验

    Spring boot集成Rabbit MQ使用初体验 1.rabbit mq基本特性 首先介绍一下rabbitMQ的几个特性 Asynchronous Messaging Supports mult ...

随机推荐

  1. C语言数组指针

    C语言中的数组指针与指针数组: ·数组指针一.区分 首先我们需要了解什么是数组指针以及什么是指针数组,如下: int *p[5];int (*p)[5];数组指针的意思即为通过指针引用数组,p先和*结 ...

  2. spi、iic、can高速传输速度与选择

    uart: 无限制,常用9600.115200bps等保证双方通信速度相同. iic: 通讯速率400Kbps can: 一般为1Mbps SPI: 通信速率 fosc/4其传输速度可达几Mb/s 缺 ...

  3. 猴子选大王的c#实现

    原文地址:猴子选大王的c#实现作者:余文 今天被问到了猴子选大王的意思,题目大意就是说有n只猴子围坐成一个圈,按顺时针方向从1到n编号.然后从1号猴子开始沿顺时针方向从1开始报数,报到m的猴子出局,再 ...

  4. 廖雪峰Java7处理日期和时间-3java.time的API-1LocalDateTime

    1.java.time提供了新的日期和时间API: LocalDate/LocalTime/LocalDateTime ZoneDateTime/ZoneId Instant Formatter 新A ...

  5. 20175311 2018-2019-2 《Java程序设计》第1周学习总结

    教材学习内容总结 第一周我们主要尝试了怎么安装各种以后可能需要用到的软件,根据老师提供的博客教程进行自主学习安装软件,然后编写一些简单的语言程序. 教材学习中的问题和解决过程 问题1:在学习过程中主要 ...

  6. 安卓打开远程调试(免root)

    首先用数据线连接adb,在pc端执行: adb tcpip 5555 然后就能拔掉数据线了. pc执行这个: adb connect 172.19.208.2 就能连接上

  7. linux 配置vue环境

    系统 [root@Gao conf.d]# uname -a 工具 1.Final Shell 2.工具截图 需要下载的部分 node.js    npm   cnpm   vue-cli 安装nod ...

  8. python——字符串问题总结

    转义符r/R使用: print (r'\n') print (R'\n') 输出: \n \n 不受转义符\n影响 python字符串格式化: print ("我叫 %s 今年 %d 岁!& ...

  9. leetcode148

    class Solution { public: ListNode* sortList(ListNode* head) { multimap<int,ListNode*> mul; whi ...

  10. STL里的内存池实现

    这个貌似有点复杂,解决的主要问题 就是 减少 内存分配次数,减少用户态核心态切换中断次数,提高运行速度,预分配 和线程池一个道理,预分配 ////////////////////自由链表 union ...