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

龙岩网站推广营销linux编辑wordpress

龙岩网站推广营销,linux编辑wordpress,假冒建设银行网站,学校网站建设实训总结概述#xff1a;安装看我上篇文章Docker安装rabbitmq-CSDN博客 任务一 创建一个队列 这样创建两个队列 在amq.fanout交换机里面发送数据 模拟发送数据 发送消息#xff0c;发现一下信息#xff1a; 所以得出理论#xff0c;消息发送是先到交换机#xff0c;然后由交换机…概述安装看我上篇文章Docker安装rabbitmq-CSDN博客 任务一 创建一个队列 这样创建两个队列 在amq.fanout交换机里面发送数据 模拟发送数据 发送消息发现一下信息 所以得出理论消息发送是先到交换机然后由交换机路由到消息队列 交换机是负责路由和转发消息的并没有存储的功能。 绑定队列 同理绑定queue2 这时再在交换机中发消息 查看结果 数据隔离 在rabbitmq中有虚拟主机的概念。 第一步新添用户 添加成功后发现没有虚拟主机也就是说我用这个用户登录后是不可以操作上面的数据的。 又因为我是超级管理员所以我能看到这些 所以只能看不能操作。 第二步创立自己的虚拟主机 第三步选自己的虚拟主机 选好后就只能看自己的了。 用Java代码操作 官网RabbitMQ Tutorials — RabbitMQ 可以看到官网上有案例我们大多情况下用的是SpringAmqp所以也就不讲那么多java简单调用的事情了。 用Spring AMQP操作 第一步在控制台里面创建一个simple.queue队列 第二步编写代码 pom文件 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdorg.cyl/groupIdartifactIdtest09/artifactIdversion0.0.1-SNAPSHOT/versionnametest09/namedescriptiontest09/descriptionpropertiesjava.version1.8/java.versionproject.build.sourceEncodingUTF-8/project.build.sourceEncodingproject.reporting.outputEncodingUTF-8/project.reporting.outputEncodingspring-boot.version2.6.13/spring-boot.version/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-amqp/artifactId/dependencydependencygroupIdcom.rabbitmq/groupIdartifactIdamqp-client/artifactIdversion5.13.0/version/dependency/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-dependencies/artifactIdversion${spring-boot.version}/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementbuildpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.8.1/versionconfigurationsource1.8/sourcetarget1.8/targetencodingUTF-8/encoding/configuration/pluginplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdversion${spring-boot.version}/versionconfigurationmainClassorg.cyl.test09.Test09Application/mainClassskiptrue/skip/configurationexecutionsexecutionidrepackage/idgoalsgoalrepackage/goal/goals/execution/executions/plugin/plugins/build/project配置mq服务端消息 spring:rabbitmq:host: 192.168.56.10port: 5672virtual-host: /cmallusername: cmallpassword: 123456 发送方 package org.cyl.test09.demos;import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class SendMessageService {Autowiredprivate RabbitTemplate rabbitTemplate;public void testSimpleQueue(){String queueNamesimple.queue;String messagehello,spring amqp!;rabbitTemplate.convertAndSend(queueName,message);}public void sendMessage(String exchange, String routingKey, Object message) {rabbitTemplate.convertAndSend(exchange, routingKey, message);} }接收方 package org.cyl.test09.demos;import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Service;Service public class ReceiveMessageService {RabbitListener(queues simple.queue)public void receiveMessage(String message) {System.out.println(接收到的消息 message);} }controller类 package org.cyl.test09.demos.controller;import org.cyl.test09.demos.ReceiveMessageService; import org.cyl.test09.demos.SendMessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;RestController public class HelloController {AutowiredSendMessageService sendMsgservice;AutowiredReceiveMessageService receiveMsgService;GetMapping(/send)public String send(){sendMsgservice.testSimpleQueue();return ok;}}展示结果 Work模型 第一步创建一个队列 第二步编写代码 发送 package org.cyl.test09.demos;import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class SendMessageService {Autowiredprivate RabbitTemplate rabbitTemplate;public void testSimpleQueue() throws InterruptedException {String queueNamework.queue;for (int i1;i50;i){String messagehello,spring amqp!_i;rabbitTemplate.convertAndSend(queueName,message);Thread.sleep(20);}}public void sendMessage(String exchange, String routingKey, Object message) {rabbitTemplate.convertAndSend(exchange, routingKey, message);} }接收 package org.cyl.test09.demos;import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Service;Service public class ReceiveMessageService {RabbitListener(queues work.queue)public void receiveMessage1(String message) {System.out.println(消费者1接收到的消息 message);}RabbitListener(queues work.queue)public void receiveMessage2(String message) {System.out.println(消费者2接收到的消息 message);} }结果展示 消费者一和消费者二是轮询效果。 Fanout交换机 第一步创建队列 第二步创建交换机并绑定 第三步编写代码 发送端 public void testFanout() {String exchangeNamecmall.fanout;String messagehello,spring everyone;rabbitTemplate.convertAndSend(exchangeName,null,message);} 接收端 RabbitListener(queues fanout.queue1)public void receiveMessage3(String message) {System.out.println(消费者1接收到的消息 message);}RabbitListener(queues fanout.queue2)public void receiveMessage4(String message) {System.out.println(消费者2接收到的消息 message);} 展示结果 私发给不同的人Direct交换机 第一步创建两个队列 第二步声明交换机并绑定 第三步编写代码 接收方 RabbitListener(queues direct.queue1)public void receiveMessage5(String message) {System.out.println(消费者1接收到的消息 message);}RabbitListener(queues direct.queue2)public void receiveMessage6(String message) {System.out.println(消费者2接收到的消息 message);} 发送方 public void testDirect1() {String exchangeNamecmall.fanout;String messagehello,spring everyone;rabbitTemplate.convertAndSend(exchangeName,red,message);}public void testDirect2() {String exchangeNamecmall.fanout;String messagehello,spring blue;rabbitTemplate.convertAndSend(exchangeName,blue,message);}public void testDirect3() {String exchangeNamecmall.fanout;String messagehello,spring yellow;rabbitTemplate.convertAndSend(exchangeName,yellow,message);} Topic交换机 这个示例代码就懒得写了。 声明交换机和队列1 绑定队列到哪个交换机里面。 一般建立关系都是在消费者这边的。 声明交换机和队列2 基于注解式声明队列和交换机。 消息转换器 字节码可变会有安全问题。 搞完以上东西代码不用变在发一次即可为json。 好了基础讲完。
http://www.sczhlp.com/news/153755/

相关文章:

  • 基于php旅游网站的毕业设计wordpress cpu
  • 以太坊网站开发桓台新城建设有限公司网站
  • 株洲网站制作公司在哪里游戏网站建设网
  • 辽宁教育网站建设费用广告策划与营销
  • 做网站让人来注册Wordpress怎么给图片加来源
  • 营销型网站的类型有哪些百度网站的域名是什么
  • 东莞做网站注意事项seo排名工具外包
  • 一条mysql数据库更新语句
  • 广州h5网站制作无忧网站建设公司
  • 遵义营销型网站建设seo流量排名软件
  • 像宝塔面板一样的建站工具西安网站建设 中讯创赢
  • 建域名做网站网站的建设与运营模式
  • 泰安公司做网站手机网站发号系统源码
  • 电子商城网站开发公司网站建设公司南宁
  • 浅谈递归入门(1) - 指南
  • python+uniapp基于微信小工具的医院陪诊预约系统
  • 网站换关键词第三方仓储配送公司
  • 用flask做的网站有哪些秦皇岛网站开发费用
  • 山东济南网站建设公司哪家好自己优化网站
  • 福州专业网站建设推广费用广州网站建设年底促销
  • gta5此网站正在建设完整html网页代码案例
  • 自己做的网站怎么挣钱代码源
  • 做网站公司深网站如何做微信推广方案设计
  • 信誉好的免费网站建设扬中网站推广服务
  • php网站开发设计做外汇看哪个网站
  • 做网站哪里的服务器速度快seo优化师就业前景
  • 前端-JavaScript简介JavaScript模块化 - 努力-
  • 基本地址变换机构
  • 手机版 演示 网站 触摸河南建站网站
  • 网站开发项目经理招聘电子商城 网站开发 支持手机端