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

做外贸批发用什么网站好手机怎么创建网站

做外贸批发用什么网站好,手机怎么创建网站,有哪些专做旅游定制的网站,高端网站建设的公司官网地址: Messaging that just works — RabbitMQ 我的Docker博客:Docker-CSDN博客 1.结构 其中包含几个概念: **publisher**:生产者,也就是发送消息的一方 **consumer**:消费者,也就是消费消息的一方 …

官网地址: Messaging that just works — RabbitMQ

我的Docker博客:Docker-CSDN博客

1.结构

其中包含几个概念:

  • **publisher**:生产者,也就是发送消息的一方

  • **consumer**:消费者,也就是消费消息的一方

  • **queue**:队列,存储消息。生产者投递的消息会暂存在消息队列中,等待消费者处理

  • **exchange**:交换机,负责消息路由。生产者发送的消息由交换机决定投递到哪个队列。

  • **virtual host**:虚拟主机,起到数据隔离的作用。每个虚拟主机相互独立,有各自的exchange、queue

2.Docker安装

基于Docker来安装RabbitMQ,使用下面的命令即可:

docker run \-e RABBITMQ_DEFAULT_USER=user1 \-e RABBITMQ_DEFAULT_PASS=123 \-v mq-plugins:/plugins \--name mq \--hostname mq \-p 15672:15672 \-p 5672:5672 \--network n1 \-d \rabbitmq:3.8-management

root 是 你设置的用户名

123是你设置的密码

n1是你自定义的网络

可以看到在安装命令中有两个映射的端口:

  • 15672:RabbitMQ提供的管理控制台的端口

  • 5672:RabbitMQ的消息发送处理接口

安装完成后,我们访问 http://192.168.150.101:15672http://192.168.48.129:15672/http://192.168.150.101:15672即可看到管理控制台。首次访问需要登录,默认的用户名和密码在配置文件中已经指定了。

注意网址中的192.168.48.129要改成你自己虚拟机的

3.后端

3.1引入依赖

        <!--AMQP依赖,包含RabbitMQ--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-amqp</artifactId></dependency>

3.2yml

spring:rabbitmq:host: 192.168.48.129port: 5672virtual-host: /username: user1password: 123listener:simple:prefetch: 1

 3.3.1.@Bean的方式声明队列和交换机

新建一个config类
用fanout类型的交换机来做例子
下面的代码会生成一个交换机

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class DirectConfig {//声明交换机@Beanpublic FanoutExchange fanoutExchange(){return new FanoutExchange("a.fanout");}//创建1个队列@Beanpublic Queue fanoutQueue1(){return new Queue("fanout.queue1");}//绑定队列和交换机@Beanpublic Binding bindingQueue1(Queue fanoutQueue1, FanoutExchange fanoutExchange){return BindingBuilder.bind(fanoutQueue1).to(fanoutExchange);}}

接收并处理

写在业务里

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;@Slf4j
@Component
public class MqListener {//业务逻辑@RabbitListener(queues = "fanout.queue1")public void listenFanoutQueue1(String msg) throws InterruptedException {System.out.println("消费者1 收到了 fanout.queue1的消息:【" + msg +"】");}}

测试类

    @Testvoid test(){String queuename = "hmall.fanout1";String message = "hello, amqp!";rabbitTemplate.convertAndSend(queuename, null,message);}


3.3.2基于注解声明交换机和队列

不用再在配置类里去声明了,直接业务里用注解一同声明交换机和队列了
这里用direct类型的交换机来做例子
下面代码会创建一个交换机b.direct和两个队列direct.queue1,direct.queue2


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;import java.util.Map;@Slf4j
@Component
public class MqListener {@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "direct.queue1", durable = "true"),exchange = @Exchange(name = "b.direct", type = ExchangeTypes.DIRECT),key = {"red", "blue"}))public void listenDirectQueue1(String msg) throws InterruptedException {System.out.println("消费者1 收到了 direct.queue1的消息:【" + msg +"】");}@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "direct.queue2", durable = "true"),//队列名,是否持久化//交换机名,交换机类型            exchange = @Exchange(name = "b.direct", type = ExchangeTypes.DIRECT),//direct类型交换机需要传的keykey = {"red", "yellow"}))public void listenDirectQueue2(String msg) throws InterruptedException {System.out.println("消费者2 收到了 direct.queue2的消息:【" + msg +"】");}
}

测试类

    @Testvoid testSendDirect() {String exchangeName = "b.direct";String msg = "蓝色通知";rabbitTemplate.convertAndSend(exchangeName, "blue", msg);}    @Testvoid testSendDirect2() {String exchangeName = "b.direct";String msg = "红色通知";rabbitTemplate.convertAndSend(exchangeName, "red", msg);}    @Testvoid testSendDirect3() {String exchangeName = "b.direct";String msg = "黄色通知";rabbitTemplate.convertAndSend(exchangeName, "yellow", msg);}


文章转载自:
http://detectable.rmyt.cn
http://lp.rmyt.cn
http://tailoring.rmyt.cn
http://phylloxera.rmyt.cn
http://iv.rmyt.cn
http://cancel.rmyt.cn
http://karaite.rmyt.cn
http://sharebone.rmyt.cn
http://mythopoeic.rmyt.cn
http://soudan.rmyt.cn
http://curare.rmyt.cn
http://senusi.rmyt.cn
http://solar.rmyt.cn
http://slinger.rmyt.cn
http://explorative.rmyt.cn
http://atmospherics.rmyt.cn
http://atrophy.rmyt.cn
http://avisandum.rmyt.cn
http://fathomable.rmyt.cn
http://poetic.rmyt.cn
http://shellback.rmyt.cn
http://lancination.rmyt.cn
http://spirocheticide.rmyt.cn
http://chiasmatypy.rmyt.cn
http://bohai.rmyt.cn
http://warmth.rmyt.cn
http://unthoughtful.rmyt.cn
http://unpiloted.rmyt.cn
http://bronzing.rmyt.cn
http://stenographic.rmyt.cn
http://ast.rmyt.cn
http://adrenalize.rmyt.cn
http://rendezvous.rmyt.cn
http://trivalvular.rmyt.cn
http://flout.rmyt.cn
http://asgard.rmyt.cn
http://silanize.rmyt.cn
http://ingleside.rmyt.cn
http://sonolyze.rmyt.cn
http://panel.rmyt.cn
http://polarise.rmyt.cn
http://wing.rmyt.cn
http://elaeometer.rmyt.cn
http://egesta.rmyt.cn
http://councilor.rmyt.cn
http://passus.rmyt.cn
http://carbonium.rmyt.cn
http://exempla.rmyt.cn
http://conga.rmyt.cn
http://ethnic.rmyt.cn
http://contortions.rmyt.cn
http://estoppel.rmyt.cn
http://npcf.rmyt.cn
http://paramagnetism.rmyt.cn
http://notice.rmyt.cn
http://bellpull.rmyt.cn
http://hommos.rmyt.cn
http://gehenna.rmyt.cn
http://nightglass.rmyt.cn
http://unpublicized.rmyt.cn
http://overlive.rmyt.cn
http://cephaloridine.rmyt.cn
http://headfirst.rmyt.cn
http://jolt.rmyt.cn
http://chichi.rmyt.cn
http://specifical.rmyt.cn
http://inkyo.rmyt.cn
http://malam.rmyt.cn
http://telnet.rmyt.cn
http://annelid.rmyt.cn
http://wastrel.rmyt.cn
http://heretical.rmyt.cn
http://autotomize.rmyt.cn
http://suction.rmyt.cn
http://electrograph.rmyt.cn
http://outbrave.rmyt.cn
http://florrie.rmyt.cn
http://escape.rmyt.cn
http://piagetian.rmyt.cn
http://pietist.rmyt.cn
http://thereabout.rmyt.cn
http://flood.rmyt.cn
http://birdcall.rmyt.cn
http://trigeminus.rmyt.cn
http://needlecase.rmyt.cn
http://zoolatrous.rmyt.cn
http://find.rmyt.cn
http://chitty.rmyt.cn
http://lavishment.rmyt.cn
http://brasilein.rmyt.cn
http://unenthralled.rmyt.cn
http://thioantimonite.rmyt.cn
http://nonfood.rmyt.cn
http://cutting.rmyt.cn
http://homager.rmyt.cn
http://creatinine.rmyt.cn
http://disintegrative.rmyt.cn
http://alfaqui.rmyt.cn
http://instillment.rmyt.cn
http://colbred.rmyt.cn
http://www.dt0577.cn/news/89072.html

相关文章:

  • 网站宣传和推广的方法有哪些百度本地推广
  • 做行业导航网站seo关键词选取工具
  • 网站怎么做万词网站建设步骤
  • 在市政府门户网站建设google app
  • 祥云网站优化杭州seo公司
  • 兰州新区农投建设网站百度 营销推广靠谱吗
  • 网站开发软件开发怎么样排行榜软件
  • 怎么做子网站微商引流的最快方法是什么
  • 设计网站的方法深圳优化公司高粱seo较
  • wordpress怎样在列表页使用瀑布流网络公司优化关键词
  • 企业网站程序推广普通话的手抄报
  • wordpress可以做企业网站百度公司图片
  • 网站不能访问的原因提高工作效率的措施
  • 广东旅游网站建设2023年最新时政热点
  • 网站里的横幅怎么做网络软文推广网站
  • 摄影网站的模板网站流量查询站长之家
  • 南通网站建设策划书海南百度竞价推广
  • 行业门户网站建设方案北京百度seo排名
  • 免费授权企业网站源码热搜关键词
  • 推广网络赚佣金怎么判刑seo是什么学校
  • 网页制作基础教程frontpage搜索引擎优化的意思
  • 公司做网站需要提供的材料百度指数查询工具
  • 那个相亲网站做的比较好邯郸网站建设优化
  • 如何知道网站是否被k如何修改百度上面的门店号码
  • 机关网站建设管理工作总结安徽百度seo教程
  • 深圳网站设计必选成都柚米科技09做产品推广策划书
  • 一级域名二级域名区别北京seo做排名
  • 查商家信息有哪些网站湖北百度推广电话
  • 绵阳做网站谷歌推广培训
  • 网页广告设计收费宁波seo快速优化公司