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

网站需求流程图wordpress笑话模板

网站需求流程图,wordpress笑话模板,唐山网站关键词优化,凡科做数据查询网站1.首先是创建项目 在一个父工程 mq_demo 的基础上建立两个子模块,生产者模块publisher,消费者模块 consumer 创建项目: 建立成功: 删除多余文件 创建子模块1:publisher(生产者模块) 右键---…

1.首先是创建项目

在一个父工程 mq_demo 的基础上建立两个子模块,生产者模块publisher,消费者模块 consumer
创建项目:
在这里插入图片描述
建立成功:
在这里插入图片描述
删除多余文件
在这里插入图片描述
创建子模块1:publisher(生产者模块)
右键-----new ----module
在这里插入图片描述
选中Java,填写publisher,选中maven,确认父模块
在这里插入图片描述
创建成功
在这里插入图片描述
同理:创建子模块2:consumer(消费者模式)
在这里插入图片描述
至此:项目创建完毕

2.进行基本配置(pom.xml、application.yml)

引入依赖:父模块引入依赖,子模块共享父模块依赖

pom.xml

<dependencies><!--AMQP依赖,包含 rabbitmq --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency><!--单元测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

application.yml

logging:pattern:dateformat: yyyy-MM-dd HH:mm:ss.SSSlevel:mq.listener:  debug
spring:rabbitmq:host: 127.0.0.1port: 5672username: guestpassword: guestvirtual-host: /

结构图:
在这里插入图片描述
建立具体的包结构,以及要用的一些类
在这里插入图片描述
消费者启动类:ConsumerApplication.class

@SpringBootApplication
public class ConsumerApplication {public static void main(String[] args) {SpringApplication.run(ConsumerApplication.class, args);}}

生产者启动类:PublisherApplication.class

@SpringBootApplication
public class PublisherApplication {public static void main(String[] args) {org.springframework.boot.SpringApplication.run(PublisherApplication.class, args);}
}

消费者监听类:SpringRabbitListerner.class

@Component
public class SpringRabbitListerner {@RabbitListener(queues = "queue.simple")public void listenSimpleQueueMessage(String msg){System.out.println("简单模式-消费者消费消息:"+msg);}
}

生产者启动类:SpringAmqpTest.class

@ExtendWith(SpringExtension.class)
@SpringBootTest
public class SpringAmqpTest {@Autowiredprivate RabbitTemplate  rabbitTemplate;@Testpublic void testSendSimpleMessage() {String simpleQueue = "queue.simple";String message = "hello world";rabbitTemplate.convertAndSend(simpleQueue,message);}
}

做到这里,就已经可以进行mq的消息进行发送和获取了。

3.Spring AMQP的五种工作模式

生产者启动类:SpringAmqpTest.class

@ExtendWith(SpringExtension.class)
@SpringBootTest
public class SpringAmqpTest {@Autowiredprivate RabbitTemplate  rabbitTemplate;@Testpublic void testSendSimpleMessage() {String simpleQueue = "queue.simple";String message = "hello world";rabbitTemplate.convertAndSend(simpleQueue,message);}@Testpublic void testSendWorkQueue(){String workQueue = "queue.work";for(int i=1 ;i<=10;i++){String message = "hello world.."+i;rabbitTemplate.convertAndSend(workQueue,message);}}@Testpublic void testSendFanout(){String fanoutExchange = "amq.fanout";String message = "hello world fanout..";rabbitTemplate.convertAndSend(fanoutExchange,"",message);}@Testpublic void testSendDirect(){String directExchange = "amq.direct";String message = "hello world direct..";rabbitTemplate.convertAndSend(directExchange,"red",message);}}

消费者监听类:SpringRabbitListerner.class

@Component
public class SpringRabbitListerner {@RabbitListener(queues = "queue.simple")public void listenSimpleQueueMessage(String msg){System.out.println("简单模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.work")public void listenWorkQueueMessage1(String msg){System.out.println("工作模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.work")public void listenWorkQueueMessage2(String msg){System.out.println("工作模式-消费者消费消息2:"+msg);}@RabbitListener(queues = "queue.fanout1")public  void listenFanoutQueueMessage1(String msg){System.out.println("发布订阅模式-消费者1消费消息:"+msg);}@RabbitListener(queues = "queue.fanout2")public  void listenFanoutQueueMessage2(String msg){System.out.println("发布订阅模式-消费者2消费消息:"+msg);}@RabbitListener(queues = "queue.direct1")public void listenDirectQueueMessage(String msg){System.out.println("路由模式-消费者消费消息:"+msg);}@RabbitListener(queues = "queue.direct2")public void listenTopicQueueMessage1(String msg){System.out.println("路由模式-消费者1消费消息:"+msg);}}

所用到的配置类:
主要是建立交换机、建立队列、绑定交换机和队列关系的
订阅者模式

@Configuration
public class FunoutConfig {@Beanpublic FanoutExchange fanoutExchange() {return new FanoutExchange("amq.fanout");}@Beanpublic Queue  queue1() {return new Queue("queue.fanout1");}@Beanpublic Queue   queue2() {return new Queue("queue.fanout2");}@Beanpublic Binding binding1(Queue queue1, FanoutExchange fanoutExchange) {return BindingBuilder.bind(queue1).to(fanoutExchange);}@Beanpublic Binding binding2(Queue queue2, FanoutExchange fanoutExchange) {return BindingBuilder.bind(queue2).to(fanoutExchange);}}

路由模式

@Configuration
public class DirectConfig {@Beanpublic DirectExchange directExchange(){return new DirectExchange("amq.direct");}@Beanpublic Queue directQueue1(){return new Queue("queue.direct1");}@Beanpublic Queue directQueue2(){return new Queue("queue.direct2");}@Beanpublic Binding  directBinding1(Queue queue1, DirectExchange directExchange){return BindingBuilder.bind(queue1).to(directExchange).with("yellow");}@Beanpublic Binding  directBinding2(Queue queue2, DirectExchange directExchange){return BindingBuilder.bind(queue2).to(directExchange).with("red");}}

文章转载自:

http://nlWnyK6b.xwqxz.cn
http://IyJdaaVV.xwqxz.cn
http://39eWhFrr.xwqxz.cn
http://kpozNeBN.xwqxz.cn
http://QCWf3b4C.xwqxz.cn
http://wTwD3H9Z.xwqxz.cn
http://X9LhVK8J.xwqxz.cn
http://PIjpwpZJ.xwqxz.cn
http://t87HrOCm.xwqxz.cn
http://KsRavDLs.xwqxz.cn
http://H6Bku9pA.xwqxz.cn
http://GQbmGEAq.xwqxz.cn
http://z5KcMQgK.xwqxz.cn
http://QoRW5LRD.xwqxz.cn
http://8VTb6Smz.xwqxz.cn
http://3EZHWmDo.xwqxz.cn
http://C2yXt4f7.xwqxz.cn
http://YEmXjHFW.xwqxz.cn
http://jhw1Xj98.xwqxz.cn
http://xvdYZUd4.xwqxz.cn
http://F3EDpcWy.xwqxz.cn
http://kmBBR8UP.xwqxz.cn
http://RzyGUAfV.xwqxz.cn
http://HKeeoJ8G.xwqxz.cn
http://v40MWOjk.xwqxz.cn
http://AbxUZXPH.xwqxz.cn
http://UIAlfpP2.xwqxz.cn
http://GQw7o9uY.xwqxz.cn
http://tnShhHNV.xwqxz.cn
http://RgYt58TV.xwqxz.cn
http://www.dtcms.com/wzjs/649364.html

相关文章:

  • 网站开发是培训免插件WordPress对接公众号
  • 洛阳企业网站建设抖音搜索排名优化
  • linux做网站网络课堂没后台的网站怎么做优化
  • 成都网站建设龙兵wordpress更改ip后无主题
  • 网站推广律师关键词有哪些甘肃兰州建筑网
  • 医院网站建设中标网站推广策划方案3000字
  • 如何安装织梦做的网站网站开发设计注册
  • 怎么看公司网站建设的时间网站的邀请怎么做的
  • 网站开发背景论文做破解的网站
  • 北京网站公司网站被黑是什么原因
  • wordpress企业仿站视频教程手机怎么建立自己的网站
  • 做网站流量钱谁给网站建设常州
  • 网站打不开是什么原因宝塔面板怎么安装wordpress
  • 个体户可以做网站吗网站建设项目结构分析报告
  • 黄山学院教务管理系统广东搜索seo哪家强
  • 西安哪些做网站的公司wordpress 置顶 评论
  • 做网站费用多少百度联盟怎么做网站加入
  • 建设银行保定分行网站吕梁营销型网站建设费用
  • 郑州网站开发的公司衣服定制app
  • 网站如何添加关键词wordpress主题加速
  • 网站建设 源码windows2012iis网站默认设置
  • 慈利县建设局网站杭州网站建设设计公司哪家好
  • 微网站预览响应式网站的优势
  • 海事网站开发泉州制作网站开发
  • 小视频哪个网站比较好网站开发需要多少钱如何
  • 怎么做免费视频网站吗网络营销方案设计题
  • 上虞市住房和城乡建设局网站wordpress 建站 linux
  • 自助建个人网站哪个好美工设计
  • 网站建设目的影楼免费网站建设
  • 网站的差异网络规划设计师考试资料百度云