artemis搭建MQTT服务端

一、下载 打开 [https://activemq.apache.org/](https://activemq.apache.org/) , 点击下载最新版本

image.png

image.png

二、解压到你的任意一个盘

image.png

三、创建一个broker实例

需要cd进入你的bin目录下打开cmd,artemis create ../myboker1 ,../myboker1 是创建的路径,当然你也可以下绝对路径/相对路径,myboker1是创建的文件夹的名字,你可以随便写,不过大家都是程序员想必大家都明白,最后别使用汉字空格全角符号这些东西当作文件夹名,否则各种神奇的bug让你痛不欲生。然后会让你输入账号密码,什么的按照提示来就行了,具体看下面:

D:\mqtt\apache-artemis-2.14.0\bin>artemis create ../myboker1
Creating ActiveMQ Artemis instance at: D:\mqtt\apache-artemis-2.14.0\myboker1

--user: is a mandatory property!
Please provide the default username:
admin

--password: is mandatory with this configuration:
Please provide the default password:


--allow-anonymous | --require-login: is a mandatory property!
Allow anonymous access?, valid values are Y,N,True,False
Y

Auto tuning journal ...
done! Your system can make 0.77 writes per millisecond, your journal-buffer-timeout will be 1296000

You can now start the broker by executing:

   "D:\mqtt\apache-artemis-2.14.0\myboker1\bin\artemis" run

Or you can setup the broker as Windows service and run it in the background:

   "D:\mqtt\apache-artemis-2.14.0\myboker1\bin\artemis-service.exe" install
   "D:\mqtt\apache-artemis-2.14.0\myboker1\bin\artemis-service.exe" start

   To stop the windows service:
      "D:\mqtt\apache-artemis-2.14.0\myboker1\bin\artemis-service.exe" stop

   To uninstall the windows service
      "D:\mqtt\apache-artemis-2.14.0\myboker1\bin\artemis-service.exe" uninstall

D:\mqtt\apache-artemis-2.14.0\bin>

这样就是OK了,然后就多了一个myboker1的文件夹,当然在你自己指定的文件夹下,我的是指定到了bin的上级目录下

image.png

然后打开etc目录
image.png

这里面都是一些配置文件,相信大家从字面意思都能看出来是干啥的,不过也就看看就行了,没啥特殊需求千万不要自己手动改这些东西,改好了你也不牛X,改不好就是傻X了。
artemis-users.properties里面放的就是你的账号密码
image.png

broker.xml打开这个,大概就在150行那个样子,这里是你不同的协议的端口

image.png

四、启动服务

cmd 进入到你的myboker1/binartemis run,等启动成功

D:\mqtt\apache-artemis-2.14.0\myartemis\bin>artemis run
     _        _               _
    / \  ____| |_  ___ __  __(_) _____
   / _ \|  _ \ __|/ _ \  \/  | |/  __/
  / ___ \ | \/ |_/  __/ |\/| | |\___ \
 /_/   \_\|   \__\____|_|  |_|_|/___ /
 Apache ActiveMQ Artemis 2.14.0


2020-08-05 15:54:38,147 INFO  [org.apache.activemq.artemis.integration.bootstrap] AMQ101000: Starting ActiveMQ Artemis Server
2020-08-05 15:54:38,180 INFO  [org.apache.activemq.artemis.core.server] AMQ221000: live Message Broker is starting with configuration Broker Configuration (clustered=false,journalDirectory=data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/large-messages,pagingDirectory=data/paging)
2020-08-05 15:54:38,205 INFO  [org.apache.activemq.artemis.core.server] AMQ221013: Using NIO Journal
2020-08-05 15:54:38,233 INFO  [org.apache.activemq.artemis.core.server] AMQ221057: Global Max Size is being adjusted to 1/2 of the JVM max size (-Xmx). being defined as 536,870,912
2020-08-05 15:54:38,261 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-server]. Adding protocol support for: CORE
2020-08-05 15:54:38,261 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-amqp-protocol]. Adding protocol support for: AMQP
2020-08-05 15:54:38,262 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-hornetq-protocol]. Adding protocol support for: HORNETQ
2020-08-05 15:54:38,269 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-mqtt-protocol]. Adding protocol support for: MQTT
2020-08-05 15:54:38,270 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-openwire-protocol]. Adding protocol support for: OPENWIRE
2020-08-05 15:54:38,270 INFO  [org.apache.activemq.artemis.core.server] AMQ221043: Protocol module found: [artemis-stomp-protocol]. Adding protocol support for: STOMP
2020-08-05 15:54:38,312 INFO  [org.apache.activemq.artemis.core.server] AMQ221034: Waiting indefinitely to obtain live lock
2020-08-05 15:54:38,313 INFO  [org.apache.activemq.artemis.core.server] AMQ221035: Live Server Obtained live lock
2020-08-05 15:54:39,263 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address DLQ supporting [ANYCAST]
2020-08-05 15:54:39,264 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue DLQ on address DLQ
2020-08-05 15:54:39,270 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST]
2020-08-05 15:54:39,270 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue
2020-08-05 15:54:40,220 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started NIO Acceptor at 0.0.0.0:61616 for protocols [CORE,MQTT,AMQP,STOMP,HORNETQ,OPENWIRE]
2020-08-05 15:54:40,229 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started NIO Acceptor at 0.0.0.0:5445 for protocols [HORNETQ,STOMP]
2020-08-05 15:54:40,238 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started NIO Acceptor at 0.0.0.0:5672 for protocols [AMQP]
2020-08-05 15:54:40,245 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started NIO Acceptor at 0.0.0.0:1883 for protocols [MQTT]
2020-08-05 15:54:40,253 INFO  [org.apache.activemq.artemis.core.server] AMQ221020: Started NIO Acceptor at 0.0.0.0:61613 for protocols [STOMP]
2020-08-05 15:54:40,260 INFO  [org.apache.activemq.artemis.core.server] AMQ221007: Server is now live
2020-08-05 15:54:40,261 INFO  [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.14.0 [0.0.0.0, nodeID=7c7c576c-d6cb-11ea-99f1-e454e8ca3ae2]
2020-08-05 15:54:40,463 INFO  [org.apache.activemq.hawtio.branding.PluginContextListener] Initialized activemq-branding plugin
2020-08-05 15:54:40,525 INFO  [org.apache.activemq.hawtio.plugin.PluginContextListener] Initialized artemis-plugin plugin
2020-08-05 15:54:41,315 INFO  [io.hawt.HawtioContextListener] Initialising hawtio services
2020-08-05 15:54:41,328 INFO  [io.hawt.system.ConfigManager] Configuration will be discovered via system properties
2020-08-05 15:54:41,329 INFO  [io.hawt.jmx.JmxTreeWatcher] Welcome to hawtio 1.5.12 : http://hawt.io/ : Don't cha wish your console was hawt like me? ;-)
2020-08-05 15:54:41,331 INFO  [io.hawt.jmx.UploadManager] Using file upload directory: D:\mqtt\apache-artemis-2.14.0\myartemis\tmp\uploads
2020-08-05 15:54:41,341 INFO  [io.hawt.web.AuthenticationFilter] Starting hawtio authentication filter, JAAS realm: "activemq" authorized role(s): "amq" role principal classes: "org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal"
2020-08-05 15:54:41,359 INFO  [io.hawt.web.JolokiaConfiguredAgentServlet] Jolokia overridden property: [key=policyLocation, value=file:/D:/mqtt/apache-artemis-2.14.0/bin/../myartemis/etc/\jolokia-access.xml]
2020-08-05 15:54:41,698 INFO  [io.hawt.web.RBACMBeanInvoker] Using MBean [hawtio:type=security,area=jmx,rank=0,name=HawtioDummyJMXSecurity] for role based access control
2020-08-05 15:54:42,253 INFO  [io.hawt.system.ProxyWhitelist] Initial proxy whitelist: [localhost, 127.0.0.1, 172.22.190.53, host.docker.internal, 192.168.30.209, DESKTOP-D3HC2F2.mshome.net, kubernetes.docker.internal]
2020-08-05 15:54:42,388 INFO  [org.apache.activemq.artemis] AMQ241001: HTTP Server started at http://localhost:8161
2020-08-05 15:54:42,388 INFO  [org.apache.activemq.artemis] AMQ241002: Artemis Jolokia REST API available at http://localhost:8161/console/jolokia
2020-08-05 15:54:42,389 INFO  [org.apache.activemq.artemis] AMQ241004: Artemis Console available at http://localhost:8161/console

五、登录控制台

打开浏览器 http://localhost:8161/console,用你刚刚保存的账号密码登录。

登录页面.png

登录成功.png

六、测试mqtt
我用的是mqttbox测试工具测试的,你们可以去官网下载,或者使用其他工具

image.png

image.png

image.png

OK部署完成,后续文章会持续更新....

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,277评论 6 503
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,689评论 3 393
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 163,624评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,356评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,402评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,292评论 1 301
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,135评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,992评论 0 275
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,429评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,636评论 3 334
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,785评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,492评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,092评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,723评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,858评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,891评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,713评论 2 354