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

建站工具箱 discuz怎么做微信小程序

建站工具箱 discuz,怎么做微信小程序,秋佐科技公司网站,wordpress调用慢文章目录 前言1.安装erlang 语言2.安装rabbitMQ3. 内网穿透3.1 安装cpolar内网穿透(支持一键自动安装脚本)3.2 创建HTTP隧道 4. 公网远程连接5.固定公网TCP地址5.1 保留一个固定的公网TCP端口地址5.2 配置固定公网TCP端口地址 前言 RabbitMQ是一个在 AMQP(高级消息队列协议)基…

文章目录

  • 前言
  • 1.安装erlang 语言
  • 2.安装rabbitMQ
  • 3. 内网穿透
    • 3.1 安装cpolar内网穿透(支持一键自动安装脚本)
    • 3.2 创建HTTP隧道
  • 4. 公网远程连接
  • 5.固定公网TCP地址
    • 5.1 保留一个固定的公网TCP端口地址
    • 5.2 配置固定公网TCP端口地址

前言

RabbitMQ是一个在 AMQP(高级消息队列协议)基础上完成的,可复用的企业消息系统,是当前最主流的消息中间件之一。
由erlang开发的AMQP(Advanced Message Queue 高级消息队列协议 )的开源实现,由于erlang 语言的高并发特性,性能较好,本质是个队列,FIFO 先入先出,里面存放的内容是message,下面介绍通过在ubuntu+cpolar+rabbitMQ环境下,实现mq服务端远程访问。

1.安装erlang 语言

由于rabbitMQ是erlang语言实现的,所以我们需要安装erlang

sudo apt-get install erlang-nox

2.安装rabbitMQ

安装最新版rabbitMQ

sudo apt-get install rabbitmq-server

image-20230227142614479

查看rabbitMQ状态,active(running)表示在线

sudo systemctl status rabbitmq-server

image-20230227142756286

设置访问MQ用户名账号和密码,admin表示账号(可自定义),123456表示密码(可自定义)

sudo rabbitmqctl add_user admin 123456

image-20230228152150865

设置上面admin用户的角色,administrator表示是最高管理员

sudo rabbitmqctl set_user_tags admin administrator

image-20230228153113674

设置admin角色权限

sudo rabbitmqctl set_permissions -p "/" admin ".*" ".*" ".*"

image-20230228153441392

以上信息设置好后,我们往下走。

3. 内网穿透

接着我们使用[cpolar](cpolar - 安全的内网穿透工具)穿透本地MQ服务,使得远程可以进行访问连接,cpolar支持http/https/tcp协议,不限制流量,操作简单,无需公网IP,也无需路由器。

cpolar官网:https://www.cpolar.com/

3.1 安装cpolar内网穿透(支持一键自动安装脚本)

  • cpolar 安装(国内使用)
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • 或 cpolar短链接安装方式:(国外使用)
curl -sL https://git.io/cpolar | sudo bash
  • 查看版本号
cpolar version
  • token认证

登录cpolar官网后台,点击左侧的验证,查看自己的认证token,之后将token贴在命令行里

cpolar authtoken xxxxxxx

20230116114805

  • 向系统添加服务
sudo systemctl enable cpolar
  • 启动cpolar服务
sudo systemctl start cpolar

正常显示为active则表示服务为正常在线启动状态

3.2 创建HTTP隧道

在ubuntu系统本地安装cpolar内网穿透之后,在ubuntu浏览器上访问本地9200端口,打开cpolar web ui界面:http://127.0.0.1:9200。

点击左侧仪表盘的隧道管理——创建隧道,由于rabbitMQ中默认的是5672端口,因此我们要来创建一条http隧道,指向5672端口:

  • 隧道名称:可自定义,注意不要重复
  • 协议:tcp
  • 本地地址:5672
  • 域名类型:选择随机域名
  • 地区:选择China VIP

点击创建

image-20230227174954395

打开在线隧道列表,查看随机公网tcp地址,使用下面随机的tcp公网地址,即可远程连接MQ

image-20230228114252675

4. 公网远程连接

maven坐标

<dependency><groupId>com.rabbitmq</groupId><artifactId>amqp-client</artifactId><version>5.10.0</version></dependency>

这里使用java 测试使用上面公网地址进行连接,编写发布者

       ConnectionFactory factory = new ConnectionFactory();//cpolar公网地址factory.setHost("1.tcp.cpolar.cn");//公网地址对于的端口号factory.setPort(24889);//用户名和密码factory.setUsername("admin");factory.setPassword("123456");Connection connection = null;Channel channel = null;try {// 1.创建连接和通道connection = factory.newConnection();channel = connection.createChannel();// 2.为通道声明exchange和exchange的类型channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.FANOUT);String msg = " hello world";// 3.发送消息到指定的exchange,队列指定为空,由exchange根据情况判断需要发送到哪些队列channel.basicPublish(EXCHANGE_NAME, "", null, msg.getBytes());System.out.println("product send a msg: " + msg);} catch (IOException e) {e.printStackTrace();} catch (TimeoutException e) {e.printStackTrace();} finally {// 4.关闭连接if (channel != null) {try {channel.close();} catch (IOException e) {e.printStackTrace();} catch (TimeoutException e) {e.printStackTrace();}}if (connection != null) {try {connection.close();} catch (IOException e) {e.printStackTrace();}}}

编写消费者

ConnectionFactory factory = new ConnectionFactory();//cpolar公网地址factory.setHost("1.tcp.cpolar.cn");//公网地址对于的端口号factory.setPort(24889);//用户名和密码factory.setUsername("admin");factory.setPassword("123456");Connection connection = null;Channel channel = null;try {// 1.创建连接和通道connection = factory.newConnection();channel = connection.createChannel();// 2.为通道声明exchange以及exchange类型channel.exchangeDeclare("exchange", BuiltinExchangeType.FANOUT);// 3.创建随机名字的队列String queueName = channel.queueDeclare().getQueue();// 4.建立exchange和队列的绑定关系channel.queueBind(queueName, "exchange", "");System.out.println(" **** Consumer1 keep alive ,waiting for messages, and then deal them");// 5.通过回调生成消费者并进行监听Consumer consumer = new DefaultConsumer(channel) {@Overridepublic void handleDelivery(String consumerTag, Envelope envelope,com.rabbitmq.client.AMQP.BasicProperties properties, byte[] body) throws IOException {// 获取消息内容然后处理String msg = new String(body, "UTF-8");System.out.println("*********** Consumer1" + " get message :[" + msg + "]");}};// 6.消费消息channel.basicConsume(queueName, true, consumer);} catch (IOException e) {e.printStackTrace();} catch (TimeoutException e) {e.printStackTrace();}

先启动消费者,然后启动发布者,然后消费者控制台输出消费者发送的消息表示成功.我们实现了远程访问MQ。

image-20230228174014355

5.固定公网TCP地址

由于以上创建的隧道使用的是随机地址隧道,地址会在24小时内变化,为了使连接更加稳定,我们还需要固定tcp地址。

5.1 保留一个固定的公网TCP端口地址

登录cpolar官网后台,点击左侧的预留,选择保留的TCP地址。

  • 地区:选择China VIP
  • 描述:即备注,可自定义填写

点击保留

image-20230228175005804

地址保留成功后,系统会生成相应的固定公网地址,将其复制下来

image-20230228175229884

5.2 配置固定公网TCP端口地址

在浏览器上访问9200端口,登录cpolar web ui管理界面,点击左侧仪表盘的隧道管理——隧道列表,找到上面创建的隧道,点击右侧的编辑

image-20230228175405748

修改隧道信息,将保留成功的固定tcp地址配置到隧道中

  • 端口类型:修改为固定tcp端口
  • 预留的tcp地址:填写保留成功的地址

点击更新

image-20230228175516881

隧道更新成功后,点击左侧仪表盘的状态在线隧道列表,找到需要编辑的隧道,可以看到公网地址已经更新成为了固定TCP地址。

image-20230228175557721

更新好后,我们修改代码中的两个参数

     	//cpolar公网地址,改为我们固定的地址factory.setHost("5.tcp.vip.cpolar.cn");//固定地址对应的端口号factory.setPort(13630);

然后我们重新启动消费者,再启动生产者,正常发布和消费消息表示成功

image-20230228175908567

转载自cpolar内网穿透的文章:无公网IP,在外公网远程访问RabbitMQ服务「内网穿透」


文章转载自:
http://dinncophlegm.bkqw.cn
http://dinncounhinge.bkqw.cn
http://dinncobarrator.bkqw.cn
http://dinncomaxi.bkqw.cn
http://dinncodelenda.bkqw.cn
http://dinncocontestee.bkqw.cn
http://dinncostreaked.bkqw.cn
http://dinncounremitted.bkqw.cn
http://dinncocarbo.bkqw.cn
http://dinncotoastmistress.bkqw.cn
http://dinncohardfern.bkqw.cn
http://dinncohers.bkqw.cn
http://dinncointestable.bkqw.cn
http://dinncozoopathology.bkqw.cn
http://dinncodeceitfully.bkqw.cn
http://dinncoseptember.bkqw.cn
http://dinncophytogenic.bkqw.cn
http://dinncooutrelief.bkqw.cn
http://dinncobronchiectasis.bkqw.cn
http://dinncohii.bkqw.cn
http://dinncomuckamuck.bkqw.cn
http://dinncocoutel.bkqw.cn
http://dinncoinfectious.bkqw.cn
http://dinncounstop.bkqw.cn
http://dinncoveblenian.bkqw.cn
http://dinncoodorless.bkqw.cn
http://dinncopredicant.bkqw.cn
http://dinncospahi.bkqw.cn
http://dinncobowfin.bkqw.cn
http://dinncoreversal.bkqw.cn
http://dinncoipy.bkqw.cn
http://dinncopaintbox.bkqw.cn
http://dinncograndeur.bkqw.cn
http://dinncosemioval.bkqw.cn
http://dinncomote.bkqw.cn
http://dinncosatinwood.bkqw.cn
http://dinncoviewpoint.bkqw.cn
http://dinncocapricorn.bkqw.cn
http://dinncohydrozincite.bkqw.cn
http://dinncobraunite.bkqw.cn
http://dinncoqua.bkqw.cn
http://dinncocoloratura.bkqw.cn
http://dinncopyrrhuloxia.bkqw.cn
http://dinncoridgetree.bkqw.cn
http://dinnconormandy.bkqw.cn
http://dinncoscleroiritis.bkqw.cn
http://dinncodna.bkqw.cn
http://dinncovictoire.bkqw.cn
http://dinncovolvox.bkqw.cn
http://dinncohitchhiker.bkqw.cn
http://dinncoshm.bkqw.cn
http://dinncogilbertese.bkqw.cn
http://dinncoovibos.bkqw.cn
http://dinncodharmsala.bkqw.cn
http://dinncopiling.bkqw.cn
http://dinncoogbomosho.bkqw.cn
http://dinncodundee.bkqw.cn
http://dinncoprotostellar.bkqw.cn
http://dinncodetick.bkqw.cn
http://dinncoconsequence.bkqw.cn
http://dinncowoofter.bkqw.cn
http://dinncosimulacrum.bkqw.cn
http://dinncodyon.bkqw.cn
http://dinncosynangium.bkqw.cn
http://dinncolickspittle.bkqw.cn
http://dinncosnobbism.bkqw.cn
http://dinncocrystallose.bkqw.cn
http://dinncoastigmatometry.bkqw.cn
http://dinncopredynastic.bkqw.cn
http://dinncocondemn.bkqw.cn
http://dinncogalla.bkqw.cn
http://dinncocottontail.bkqw.cn
http://dinncowaterspout.bkqw.cn
http://dinncoissa.bkqw.cn
http://dinncoempiricist.bkqw.cn
http://dinncouncap.bkqw.cn
http://dinncobroederbond.bkqw.cn
http://dinncoracking.bkqw.cn
http://dinncoradiophone.bkqw.cn
http://dinncopachydermatous.bkqw.cn
http://dinncoorbicularis.bkqw.cn
http://dinncopublicise.bkqw.cn
http://dinncodb.bkqw.cn
http://dinncoembrittle.bkqw.cn
http://dinncosongcraft.bkqw.cn
http://dinncopyrenees.bkqw.cn
http://dinncopapalize.bkqw.cn
http://dinncoiata.bkqw.cn
http://dinncoreasoningly.bkqw.cn
http://dinncoadjunct.bkqw.cn
http://dinncomopery.bkqw.cn
http://dinncoprebendal.bkqw.cn
http://dinncoanimator.bkqw.cn
http://dinncoacus.bkqw.cn
http://dinncopolyoxymethylene.bkqw.cn
http://dinncointrenchingtool.bkqw.cn
http://dinncopalliate.bkqw.cn
http://dinnconoser.bkqw.cn
http://dinncosoundproof.bkqw.cn
http://dinncofostress.bkqw.cn
http://www.dinnco.com/news/93930.html

相关文章:

  • 做网站的收获网络营销中心
  • 优秀网站开发网站权重
  • 网站经常修改好不好百度账号注册中心
  • wordpress四级级分类目录搜索引擎seo优化
  • 重庆市建设工程信息网官网查询证天津seo
  • 无锡企业网站制作公司有哪些个人开发app最简单方法
  • 西安网站制作工作室百度seo排名优化价格
  • 潍坊网站建设哪里好营销模式方案
  • 安徽徐州网站建设公司今晚日本比分预测
  • 新余百度网站建设百度seo快速排名
  • 做网站的话 java和c营销qq下载
  • 市政府网站开发实例不要手贱搜这15个关键词
  • 成都专业app开发服务重庆seo公司怎么样
  • 丰联汽配网站建设成本针对大学生推广引流
  • 网站图片做伪静态可以打广告的平台
  • 福建定制网站开发企业培训课程安排表
  • 自学做动态网站怎样在百度上发表文章
  • 西安网站建设高端如何接广告赚钱
  • 网站返回500错误页面优化用户体验
  • 湘潭公司做网站百度网址怎么输入?
  • 看女人和男人做鸡的网站seo网站推广教程
  • wordpress标签页固定链接seo站长工具查询
  • 益阳网站开发网站关键词优化有用吗
  • 做类似起点的网站福州排名seo公司
  • seo网站查询工具如何自己做一个网址
  • 邢台物流网站建设seo效果检测步骤
  • 自己做头像的网站漫画网络营销出来做什么
  • 视频优化网站怎么做seo推广营销靠谱
  • 天河手机网站建设什么网站百度收录快
  • 网页ui设计培训seo是什么意思 为什么要做seo