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. sql job定时备份数据库

    ---------------------------------------- 对TestDB1进行备份 ---------------------------------------- decla ...

  2. LeetCode - 刷题经验

    1.加快代码速度 刷了前面几道题发现速度总是处于尾部10%,刚开始非常不服,后来仔细一看那些排名靠前的提交,发现了猫腻.几乎每一个提交都有这样的一段代码: static const auto io_s ...

  3. Python发送微信消息

    针对此 需要安装itchat第三方模块 采用pip安装就可以了   pip install itchat import itchatimport time#引入时间函数进行测试time_format= ...

  4. enctype=“multipart/form-data”详解

    enctype这个属性管理的是表单的MIME(Multipurpose Internet Mail Extensions)编码,共有三个值可选: 1.application/x-www-form-ur ...

  5. k8s学习笔记之六:Pod控制器(kube-controller-manager)

    第一章.什么是kube-controller-manager? Controller Manager 由 kube-controller-manager 和 cloud-controller-mana ...

  6. Vue 折叠面板Collapse在标题上添加组件后,阻止面板冒泡的用法

    iView组件中,折叠面板Collapse点击面板标题部分,会出现面板收起或展开的效果.那么在面板标题后面再添加下拉框之类的组件时,会出现跟面板点击一样的效果,这时候就需要阻止冒泡的用法了.具体代码: ...

  7. android 开发 View _13 绘制图片与BitmapShader位图的图像渲染器

    BitmapShader位图的图像渲染器 TileMode 模式 Shader.TileMode.CLAMP 边缘拉伸. Shader.TileMode.MIRROR 在水平方向和垂直方向交替景象, ...

  8. IntelliJ IDEA 性能优化

    idea打开的多了 内存占用也就多了 下边是亲试的优化ide性能的方法 1.设置JVM的启动参数: 进入idea的安装目录的bin文件夹 打开 idea.exe.vmoptions 文件, 修改-Xm ...

  9. How to solve “Dynamic Web Module 3.1 requires Java 1.7 or newer” in Eclipse

    How to solve “Dynamic Web Module 3.1 requires Java 1.7 or newer” in Eclipse Last updated on June 20t ...

  10. C# 对Excel操作与分析

    今天帮现在饿公司写个工具,要动态读excel上的ip地址与端口号,来更改IE的代理地址,由于好久没写Excel的操作了,只能查阅以前的项目,总结一下: 首先我们要引用我们的com接口的excelMic ...