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. spring4.0之二:@Configuration的使用

    从Spring3.0,@Configuration用于定义配置类,可替换xml配置文件,被注解的类内部包含有一个或多个被@Bean注解的方法,这些方法将会被AnnotationConfigApplic ...

  2. python开发购物车

    1 业务需求 商品中心 显示库存的商品 商品能够加入到购物车 个人中心 购物车 修改购物车的商品 下单 完成的订单 订单详情 账户余额 2 代码实现 # 定义全局变量信息 # 商品编号信息 goods ...

  3. Spring系列博客汇总

    https://www.cnblogs.com/leeSmall/category/1093236.html   springmvc https://www.cnblogs.com/leeSmall/ ...

  4. Android Studio2.0 教程从入门到精通Windows版

    系列教程 Android Studio2.0 教程从入门到精通Windows版 - 安装篇Android Studio2.0 教程从入门到精通Windows版 - 入门篇Android Studio2 ...

  5. RF:操作笔记

    1.变量运算

  6. Maven私服(Nexus)资源上传下载

    1.settings.xml (向私服上传资源需要) <!-- Snapshot包的管理/Releases包的管理/第三方包管理--> <server> <id>l ...

  7. hive 表锁和解锁

    场景: 在执行insert into或insert overwrite任务时,中途手动将程序停掉,会出现卡死情况(无法提交MapReduce),只能执行查询操作,而drop insert操作均不可操作 ...

  8. hadoop 二次排序的思考

    name sorce jx 10 gj 15 jx 20 gj 30 1. 二次排序 key如何定义 2. grouping 是不是一定要实现,不实现可以吗? 3. 二次排序的本质是什么 4. 如果以 ...

  9. script 写在body和head的区别(WEUI中使用swiper删除)

    区别简述: 在HTML body部分中的JavaScripts会在页面加载的时候被执行.在HTML head部分中的JavaScripts会在被调用的时候才执行.   JavaScript应放在哪里 ...

  10. Flink架构、原理与部署测试(转)

    Apache Flink是一个面向分布式数据流处理和批量数据处理的开源计算平台,它能够基于同一个Flink运行时,提供支持流处理和批处理两种类型应用的功能. 现有的开源计算方案,会把流处理和批处理作为 ...