扩展插件

扩展插件

EMQ X 消息服务器通过模块注册和钩子(Hooks)机制,支持用户开发扩展插件定制服务器认证鉴权与业务功能。

EMQ X 官方提供的插件包括:

插件 配置文件 说明
emqx_dashboard 扩展插件 - 图1 (opens new window) + etc/plugins/emqx_dashbord.conf Web 控制台插件(默认加载)
emqx_management 扩展插件 - 图2 (opens new window) + etc/plugins/emqx_management.conf HTTP API 与 CLI 管理插件
emqx_psk_file 扩展插件 - 图3 (opens new window) + etc/plugins/emqx_psk_file.conf PSK 支持
emqx_web_hook 扩展插件 - 图4 (opens new window) + etc/plugins/emqx_web_hook.conf Web Hook 插件
emqx_lua_hook 扩展插件 - 图5 (opens new window) + etc/plugins/emqx_lua_hook.conf Lua Hook 插件
emqx_retainer 扩展插件 - 图6 (opens new window) + etc/plugins/emqx_retainer.conf Retain 消息存储模块
emqx_rule_engine 扩展插件 - 图7 (opens new window) + etc/plugins/emqx_rule_engine.conf 规则引擎
emqx_bridge_mqtt 扩展插件 - 图8 (opens new window) + etc/plugins/emqx_bridge_mqtt.conf MQTT 消息桥接
emqx_delayed_publish 扩展插件 - 图9 (opens new window) + etc/plugins/emqx_delayed_publish.conf 客户端延时发布消息支持
emqx_coap 扩展插件 - 图10 (opens new window) + etc/plugins/emqx_coap.conf CoAP 协议支持
emqx_lwm2m 扩展插件 - 图11 (opens new window) + etc/plugins/emqx_lwm2m.conf LwM2M 协议支持
emqx_sn 扩展插件 - 图12 (opens new window) + etc/plugins/emqx_sn.conf MQTT-SN 协议支持
emqx_stomp 扩展插件 - 图13 (opens new window) + etc/plugins/emqx_stomp.conf Stomp 协议支持
emqx_recon 扩展插件 - 图14 (opens new window) + etc/plugins/emqx_recon.conf Recon 性能调试
emqx_reloader 扩展插件 - 图15 (opens new window) + etc/plugins/emqx_reloader.conf Reloader 代码热加载插件
emqx_plugin_template 扩展插件 - 图16 (opens new window) + etc/plugins/emqx_plugin_template.conf 插件开发模版

其中插件的加载有四种方式:

  1. 默认加载
  2. 命令行启停插件
  3. 使用 Dashboard 启停插件
  4. 调用管理 API 启停插件

开启默认加载

如需在系统启动时就默认启动某插件,则直接在 data/loaded_plugins 配置入需要启动的插件,例如默认开启的加载的插件有:

emqx_management.
emqx_rule_engine.
emqx_recon.
emqx_retainer.
emqx_dashboard.

命令行启停插件

在运行过程中,我们可以通过 CLI 命令的方式查看可用的插件列表、和启停某插件:

## 显示所有可用的插件列表
./bin/emqx_ctl plugins list

## 加载某插件
./bin/emqx_ctl plugins load emqx_auth_username

## 卸载某插件
./bin/emqx_ctl plugins unload emqx_auth_username

## 重新加载某插件
./bin/emqx_ctl plugins reload emqx_auth_username

使用 Dashboard 启停插件

如果 EMQ X 开启了 Dashbord 的插件(默认开启) 还可以直接通过访问 http://localhost:18083/plugins 中的插件管理页面启停、或者配置插件。