下载到本地的文件,我下载两个,一个是 JDK,一个是 JRE,大家只下载一个就好。
2)、安装JDK步骤没有什么可说的,直接下一步就可以,根据自己的需求更改就可以。
右键”计算机” => ”属性” => ”高级系统设置” => ”高级” => “环境变量” => “系统变量”。
变量名:JAVA_HOME
变量值:D:\program files\Java\jdk-1.8【具体要根据你自己的安装路径,我的是安装在D盘的】
变量名:CLASSPATH
变量值:%JAVA_HOME%/lib/dt.jar;%JAVA_HOME/%/lib/tools.jar
2、下载、配置 Apollo 服务器。
成功创建文件夹。
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 <!-- 3 Licensed to the Apache Software Foundation (ASF) under one or more 4 contributor license agreements. See the NOTICE file distributed with 5 this work for additional information regarding copyright ownership. 6 The ASF licenses this file to You under the Apache License, Version 7 2.0 (the "License"); you may not use this file except in compliance 8 with the License. You may obtain a copy of the License at 9 http://www.apache.org/licenses/LICENSE-2.0 Unless required by 10 applicable law or agreed to in writing, software distributed under 11 the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 12 OR CONDITIONS OF ANY KIND, either express or implied. See the 13 License for the specific language governing permissions and 14 limitations under the License. 15 --> 16 17 <!-- 18 For more information on how configure this file please 19 reference: 20 21 http://activemq.apache.org/apollo/versions/1.7.1/website/documentation/user-manual.html 22 --> 23 <broker xmlns="http://activemq.apache.org/schema/activemq/apollo"> 24 25 <notes> 26 The default configuration with tls/ssl enabled. 27 </notes> 28 29 <log_category console="console" security="security" connection="connection" audit="audit"/> 30 31 32 <authentication domain="apollo"/> 33 <!-- Give admins full access --> 34 <access_rule allow="admins" action="*"/> 35 <access_rule allow="*" action="connect" kind="connector"/> 36 37 38 <virtual_host id="mqttServer"> 39 <!-- 40 You should add all the host names that this virtual host is known as 41 to properly support the STOMP 1.1 virtual host feature. 42 --> 43 <host_name>mqttServer</host_name> 44 <host_name>localhost</host_name> 45 <host_name>127.0.0.1</host_name> 46 47 <!-- Uncomment to disable security for the virtual host --> 48 <!-- <authentication enabled="false"/> --> 49 50 <!-- Uncomment to disable security for the virtual host --> 51 <!-- <authentication enabled="false"/> --> 52 <access_rule allow="users" action="connect create destroy send receive consume"/> 53 54 55 <!-- You can delete this element if you want to disable persistence for this virtual host --> 56 <leveldb_store directory="${apollo.base}/data"/> 57 58 59 </virtual_host> 60 //Web网站系统访问的IP地址,127.0.0.1,这样定义只能内网访问,如果想外网访问,改成:0.0.0.0,格式:http://1**.9*.11*.1**:61680/console/index.html# 61 <web_admin bind="http://0.0.0.0:61680"/> 62 <web_admin bind="https://0.0.0.0:61681"/> 63 //这是MQTT服务器的地址,在使用MQTT客户端访问MQTT服务器的格式:云服务器公网地址(不是执行ipconfig获取的地址):端口号,格式:1**.9*.11*.1**:61613 64 <connector id="tcp" bind="tcp://0.0.0.0:61613" connection_limit="2000"/> 65 <connector id="tls" bind="tls://0.0.0.0:61614" connection_limit="2000"/> 66 <connector id="ws" bind="ws://0.0.0.0:61623" connection_limit="2000"/> 67 <connector id="wss" bind="wss://0.0.0.0:61624" connection_limit="2000"/> 68 69 <key_storage file="${apollo.base}/etc/keystore" password="password" key_password="password"/> 70 71 </broker>
源码如下:
1 ## --------------------------------------------------------------------------- 2 ## Licensed to the Apache Software Foundation (ASF) under one or more 3 ## contributor license agreements. See the NOTICE file distributed with 4 ## this work for additional information regarding copyright ownership. 5 ## The ASF licenses this file to You under the Apache License, Version 2.0 6 ## (the "License"); you may not use this file except in compliance with 7 ## the License. You may obtain a copy of the License at 8 ## 9 ## http://www.apache.org/licenses/LICENSE-2.0 10 ## 11 ## Unless required by applicable law or agreed to in writing, software 12 ## distributed under the License is distributed on an "AS IS" BASIS, 13 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ## See the License for the specific language governing permissions and 15 ## limitations under the License. 16 ## --------------------------------------------------------------------------- 17 18 # 19 # The list of users that can login. This file supports both plain text or 20 # encrypted passwords. Here is an example what an encrypted password 21 # would look like: 22 # 23 # admin=ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL) 24 # 25 26 admin=password
源码如下:
1 ## --------------------------------------------------------------------------- 2 ## Licensed to the Apache Software Foundation (ASF) under one or more 3 ## contributor license agreements. See the NOTICE file distributed with 4 ## this work for additional information regarding copyright ownership. 5 ## The ASF licenses this file to You under the Apache License, Version 2.0 6 ## (the "License"); you may not use this file except in compliance with 7 ## the License. You may obtain a copy of the License at 8 ## 9 ## http://www.apache.org/licenses/LICENSE-2.0 10 ## 11 ## Unless required by applicable law or agreed to in writing, software 12 ## distributed under the License is distributed on an "AS IS" BASIS, 13 ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ## See the License for the specific language governing permissions and 15 ## limitations under the License. 16 ## --------------------------------------------------------------------------- 17 18 # 19 # Allows you to place multiple users in a group. 20 # Example: 21 # 22 # power_users=admin|chirino 23 # 24 admins=admin
7)、客户端(外网客户端和服务器本地,访问方式不同)测试运行。
2】、通过services.msc 命令查看服务。
【2】、打开配置窗口如下:
【3】、回到主界面,点击connect连接到MQTT 代理服务器上,就可以进行订阅和发布消息测试了。
【4】、Publish 发布测试。(主题:这是测试,内容:this is my test 2023.7.13)
【5】Subscribe即订阅(订阅该主题之后,每次发布消息均会收到通知)
【6】、链接成功之后,在apache-apollo管理平台可以看到有一个链接存在了