当前位置: 首页 > news >正文

网站需要哪些百度网址大全旧版本

网站需要哪些,百度网址大全旧版本,在哪个网站上面可以接项目做,如何做网站报价一、步骤 生产者 ① 创建生产者工程 ② 添加依赖 ③ 配置整合 ④ 编写代码发送消息 消费者 ① 创建消费者工程 ② 添加依赖 ③ 配置整合 ④ 编写消息监听器 二、代码 生产者工程 1.在生产者工程和消费者工程中都导入如下依赖 <dependencies><dependency&g…

一、步骤

生产者

① 创建生产者工程
② 添加依赖
③ 配置整合
④ 编写代码发送消息

消费者

① 创建消费者工程
② 添加依赖
③ 配置整合
④ 编写消息监听器

二、代码

生产者工程

1.在生产者工程和消费者工程中都导入如下依赖

<dependencies><dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId><version>5.1.7.RELEASE</version></dependency><dependency><groupId>org.springframework.amqp</groupId><artifactId>spring-rabbit</artifactId><version>2.1.8.RELEASE</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.1.7.RELEASE</version></dependency>
</dependencies>
<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version><configuration><source>1.8</source><target>1.8</target></configuration></plugin></plugins>
</build>

 2.生产者和消费者 导入配置文件   rabbitmq.properties

rabbitmq.host=43.143.246.208
rabbitmq.port=5672
rabbitmq.username=root
rabbitmq.password=root
rabbitmq.virtual-host=/itcast

3.生产者核心配置文件  spring-rabbitmq-producer.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:context="http://www.springframework.org/schema/context"xmlns:rabbit="http://www.springframework.org/schema/rabbit"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/rabbithttp://www.springframework.org/schema/rabbit/spring-rabbit.xsd"><!--加载配置文件--><context:property-placeholder location="classpath:rabbitmq.properties"/><!-- 定义rabbitmq connectionFactory --><rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}"port="${rabbitmq.port}"username="${rabbitmq.username}"password="${rabbitmq.password}"virtual-host="${rabbitmq.virtual-host}"/><!--定义管理交换机、队列--><rabbit:admin connection-factory="connectionFactory"/><!--定义持久化队列,不存在则自动创建;不绑定到交换机则绑定到默认交换机默认交换机类型为direct,名字为:"",路由键为队列的名称--><rabbit:queue id="spring_queue" name="spring_queue" auto-declare="true"/><!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~广播;所有队列都能收到消息~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --><!--定义广播交换机中的持久化队列,不存在则自动创建--><rabbit:queue id="spring_fanout_queue_1" name="spring_fanout_queue_1" auto-declare="true"/><!--定义广播交换机中的持久化队列,不存在则自动创建--><rabbit:queue id="spring_fanout_queue_2" name="spring_fanout_queue_2" auto-declare="true"/><!--定义广播类型交换机;并绑定上述两个队列--><rabbit:fanout-exchange id="spring_fanout_exchange" name="spring_fanout_exchange" auto-declare="true"><rabbit:bindings><rabbit:binding queue="spring_fanout_queue_1"/><rabbit:binding queue="spring_fanout_queue_2"/></rabbit:bindings></rabbit:fanout-exchange><!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~通配符;*匹配一个单词,#匹配多个单词 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --><!--定义广播交换机中的持久化队列,不存在则自动创建--><rabbit:queue id="spring_topic_queue_star" name="spring_topic_queue_star" auto-declare="true"/><!--定义广播交换机中的持久化队列,不存在则自动创建--><rabbit:queue id="spring_topic_queue_well" name="spring_topic_queue_well" auto-declare="true"/><!--定义广播交换机中的持久化队列,不存在则自动创建--><rabbit:queue id="spring_topic_queue_well2" name="spring_topic_queue_well2" auto-declare="true"/><rabbit:topic-exchange id="spring_topic_exchange" name="spring_topic_exchange" auto-declare="true"><rabbit:bindings><rabbit:binding pattern="root.*" queue="spring_topic_queue_star"/><rabbit:binding pattern="root.#" queue="spring_topic_queue_well"/><rabbit:binding pattern="itcast.#" queue="spring_topic_queue_well2"/></rabbit:bindings></rabbit:topic-exchange><!--定义rabbitTemplate对象操作可以在代码中方便发送消息--><rabbit:template id="rabbitTemplate" connection-factory="connectionFactory"/>
</beans>

4.测试类 ProducerTest

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-rabbitmq-producer.xml")
public class ProducerTest {//1.注入 RabbitTemplate@Autowiredprivate RabbitTemplate rabbitTemplate;@Testpublic void testHelloWorld(){//2.发送消息rabbitTemplate.convertAndSend("spring_queue","hello world spring....");}/*** 发送fanout消息*/@Testpublic void testFanout(){//2.发送消息rabbitTemplate.convertAndSend("spring_fanout_exchange","","spring fanout....");}/*** 发送topic消息*/@Testpublic void testTopic(){//2.发送消息rabbitTemplate.convertAndSend("spring_topic_exchange","root.hehe.haha","spring topic....");}
}

5.运行结果 

 消费者工程

1、2同上述1、2

3、消费者核心配置文件

<?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:context="http://www.springframework.org/schema/context"xmlns:rabbit="http://www.springframework.org/schema/rabbit"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttps://www.springframework.org/schema/context/spring-context.xsdhttp://www.springframework.org/schema/rabbithttp://www.springframework.org/schema/rabbit/spring-rabbit.xsd"><!--加载配置文件--><context:property-placeholder location="classpath:rabbitmq.properties"/><!-- 定义rabbitmq connectionFactory --><rabbit:connection-factory id="connectionFactory" host="${rabbitmq.host}"port="${rabbitmq.port}"username="${rabbitmq.username}"password="${rabbitmq.password}"virtual-host="${rabbitmq.virtual-host}"/><!-- 定义SpringQueueListener --><bean id="springQueueListener" class="com.rabbitmq.listener.SpringQueueListener"/>
<!--    <bean id="fanoutListener1" class="com.rabbitmq.listener.FanoutListener1"/>-->
<!--    <bean id="fanoutListener2" class="com.rabbitmq.listener.FanoutListener2"/>-->
<!--    <bean id="topicListenerStar" class="com.rabbitmq.listener.TopicListenerStar"/>-->
<!--    <bean id="topicListenerWell" class="com.rabbitmq.listener.TopicListenerWell"/>-->
<!--    <bean id="topicListenerWell2" class="com.rabbitmq.listener.TopicListenerWell2"/>--><rabbit:listener-container connection-factory="connectionFactory" auto-declare="true"><!-- 定义SpringQueueListener 监听哪个队列--><rabbit:listener ref="springQueueListener" queue-names="spring_queue"/>
<!--        <rabbit:listener ref="fanoutListener1" queue-names="spring_fanout_queue_1"/>-->
<!--        <rabbit:listener ref="fanoutListener2" queue-names="spring_fanout_queue_2"/>-->
<!--        <rabbit:listener ref="topicListenerStar" queue-names="spring_topic_queue_star"/>-->
<!--        <rabbit:listener ref="topicListenerWell" queue-names="spring_topic_queue_well"/>-->
<!--        <rabbit:listener ref="topicListenerWell2" queue-names="spring_topic_queue_well2"/>--></rabbit:listener-container>
</beans>

4.类 SpringQueueListener

public class SpringQueueListener implements MessageListener {@Overridepublic void onMessage(Message message) {//打印消息System.out.println(new String(message.getBody()));}
}

5.测试

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-rabbitmq-comsumer.xml")
public class ConsumerTest {@Testpublic void test1(){boolean flag = true;while (true){}}}


文章转载自:
http://dinncocorkwood.wbqt.cn
http://dinncoergotinine.wbqt.cn
http://dinncolandowner.wbqt.cn
http://dinncococcolith.wbqt.cn
http://dinncoaccelerando.wbqt.cn
http://dinncocrashworthiness.wbqt.cn
http://dinncopertinacity.wbqt.cn
http://dinncoarrival.wbqt.cn
http://dinncojuxtaglomerular.wbqt.cn
http://dinncoweigher.wbqt.cn
http://dinncomucker.wbqt.cn
http://dinncointerzone.wbqt.cn
http://dinncoecstatically.wbqt.cn
http://dinncoleathercoat.wbqt.cn
http://dinncoforeseeable.wbqt.cn
http://dinncopapillary.wbqt.cn
http://dinncotankstand.wbqt.cn
http://dinncoclash.wbqt.cn
http://dinncosowbread.wbqt.cn
http://dinncowashbowl.wbqt.cn
http://dinncounderwaist.wbqt.cn
http://dinncotripmeter.wbqt.cn
http://dinncocosmetic.wbqt.cn
http://dinncoshirker.wbqt.cn
http://dinncophotosynthesize.wbqt.cn
http://dinncotarsi.wbqt.cn
http://dinncoadverbial.wbqt.cn
http://dinncoordo.wbqt.cn
http://dinncosustained.wbqt.cn
http://dinncopatently.wbqt.cn
http://dinncooutmatch.wbqt.cn
http://dinncountenanted.wbqt.cn
http://dinncodissociable.wbqt.cn
http://dinncopythagorean.wbqt.cn
http://dinncoadventureful.wbqt.cn
http://dinncohabatsu.wbqt.cn
http://dinncoforwearied.wbqt.cn
http://dinncohellbender.wbqt.cn
http://dinncobusier.wbqt.cn
http://dinncomisogyny.wbqt.cn
http://dinncounguarded.wbqt.cn
http://dinncoparticularization.wbqt.cn
http://dinncotamale.wbqt.cn
http://dinncomisapplication.wbqt.cn
http://dinncorifler.wbqt.cn
http://dinncosonance.wbqt.cn
http://dinncolinty.wbqt.cn
http://dinncoeyewinker.wbqt.cn
http://dinncoputatively.wbqt.cn
http://dinncomischievously.wbqt.cn
http://dinncofavorer.wbqt.cn
http://dinncoperquisition.wbqt.cn
http://dinncoprofanity.wbqt.cn
http://dinncosubsternal.wbqt.cn
http://dinncoloo.wbqt.cn
http://dinncoannihilation.wbqt.cn
http://dinncowcdma.wbqt.cn
http://dinncosocietal.wbqt.cn
http://dinncodam.wbqt.cn
http://dinncoguestly.wbqt.cn
http://dinncoaudiogram.wbqt.cn
http://dinncolunger.wbqt.cn
http://dinncomatelot.wbqt.cn
http://dinncoshitticism.wbqt.cn
http://dinncoradioactinium.wbqt.cn
http://dinncocrossness.wbqt.cn
http://dinncobatiste.wbqt.cn
http://dinncoturgid.wbqt.cn
http://dinncocommunitarian.wbqt.cn
http://dinncomicroslide.wbqt.cn
http://dinnconeckband.wbqt.cn
http://dinncoila.wbqt.cn
http://dinncovisive.wbqt.cn
http://dinncofalcial.wbqt.cn
http://dinncoharicot.wbqt.cn
http://dinncosubtropical.wbqt.cn
http://dinncoeffectuation.wbqt.cn
http://dinncoleah.wbqt.cn
http://dinncozinc.wbqt.cn
http://dinncoritualism.wbqt.cn
http://dinncoribose.wbqt.cn
http://dinncodnestr.wbqt.cn
http://dinncolamplerss.wbqt.cn
http://dinncocataleptiform.wbqt.cn
http://dinncokinesiology.wbqt.cn
http://dinncooil.wbqt.cn
http://dinncocarey.wbqt.cn
http://dinncodecay.wbqt.cn
http://dinncofiner.wbqt.cn
http://dinncoantipode.wbqt.cn
http://dinncoscarabaeus.wbqt.cn
http://dinncorefrigeratory.wbqt.cn
http://dinncojester.wbqt.cn
http://dinncocontainerport.wbqt.cn
http://dinncokogai.wbqt.cn
http://dinncohoudan.wbqt.cn
http://dinnconeanic.wbqt.cn
http://dinncomirthless.wbqt.cn
http://dinncofidley.wbqt.cn
http://dinncomicrography.wbqt.cn
http://www.dinnco.com/news/160771.html

相关文章:

  • cvm可以做网站服务器吗搜索引擎seo如何优化
  • 网页提示站点不安全网站站长seo推广
  • 网站做营利性广告需要什么备案游戏推广引流
  • 360建筑网中级机械工程师招聘高级seo是什么职位
  • 自己搭建网站要钱吗百度站内搜索提升关键词排名
  • 网站免费优化网络营销策划ppt范例
  • 自己买主机可以做网站吗谷歌seo外链
  • wordpress如何开启多站点公司注册流程
  • 网站建设方案打包代运营公司是怎么运营的
  • 找回网站后台百度一下你就知道官网百度
  • 哪个网站做废旧好哪个app可以找培训班
  • 专业网站建设微信网站定制比较有名的个人网站
  • 研发网站要多长时间seo优化是利用规则提高排名
  • 成都网站建设开发价格优化关键词有哪些方法
  • 川畅联系 做网站多少钱在线网页服务器
  • 小微企业所得税5%优惠政策青岛seo整站优化招商电话
  • 做英文网站挂谷歌广告魔方优化大师官网下载
  • 域名网站注册认证百度识图官网
  • 如何制作h5做网站爱站seo查询
  • 做电子商务网站注册哪一类商标千万不要做手游推广员
  • 天津做网站网页的公司自己开发网站怎么盈利
  • 网站建设 在电商的作用长沙企业网站建设报价
  • 中企动力网站建设方案太原最新情况
  • 淘宝这种网站怎么做的石家庄seo网站管理
  • 天津企业网站设计哪家好临沂做网络优化的公司
  • 网站颜色搭配网站站长之家排行榜
  • 大型行业门户网站开发建设参考网是合法网站吗?
  • wordpress微云解析插件seo优化专员编辑
  • 彩票网站开发注意事情无锡seo
  • 可以做仿真实验的网站分类达人的作用