diff --git a/README.md b/README.md index 90d665cf5d671dab5e95e24e01ecf93d77d57bba..0d997c03a50a65559eaaa6928605234f4060d175 100644 --- a/README.md +++ b/README.md @@ -78,61 +78,70 @@ SMQTT基于Netty开发,底层采用Reactor3反应堆模型,支持单机部署 阻塞式启动服务: ```markdown -Bootstrap.builder() - .rootLevel(Level.INFO) - .wiretap(false) - .port(8555) - .websocketPort(8999) - .options(channelOptionMap -> { })//netty options设置 - .childOptions(channelOptionMap -> { }) //netty childOptions设置 - .highWaterMark(1000000) - .reactivePasswordAuth((U, P) -> true) - .lowWaterMark(1000) - .ssl(false) - .sslContext(new SslContext("crt", "key")) - .isWebsocket(true) - .httpOptions(Bootstrap.HttpOptions.builder().enableAdmin(true).ssl(false).accessLog(true).build()) - .clusterConfig( - ClusterConfig.builder() - .clustered(false) + Bootstrap bootstrap = Bootstrap.builder() + .rootLevel(Level.DEBUG) + .tcpConfig( + BootstrapConfig + .TcpConfig + .builder() + .port(8888) + .username("smqtt") + .password("smqtt") + .build()) + .httpConfig( + BootstrapConfig + .HttpConfig + .builder() + .enable(true) + .accessLog(true) + .build()) + .clusterConfig( + BootstrapConfig. + ClusterConfig + .builder() + .enable(true) + .namespace("smqtt") + .node("node-1") .port(7773) - .nodeName("node-2") - .clusterUrl("127.0.0.1:7771,127.0.0.1:7772") - .build() - ) - .started(bootstrap->{}) - .build() - .startAwait(); + .url("127.0.0.1:7771,127.0.0.1:7772"). + build()) + .build() + .startAwait(); ``` 非阻塞式启动服务: ```markdown -Bootstrap bootstrap = Bootstrap.builder() - .rootLevel(Level.INFO) - .wiretap(false) - .port(8555) - .websocketPort(8999) - .options(channelOptionMap -> { })//netty options设置 - .childOptions(channelOptionMap -> { }) //netty childOptions设置 - .highWaterMark(1000000) - .reactivePasswordAuth((U, P) -> true) - .lowWaterMark(1000) - .ssl(false) - .sslContext(new SslContext("crt", "key")) - .isWebsocket(true) - .httpOptions(Bootstrap.HttpOptions.builder().enableAdmin(true).ssl(false).accessLog(true).build()) - .clusterConfig( - ClusterConfig.builder() - .clustered(false) + + Bootstrap bootstrap = Bootstrap.builder() + .rootLevel(Level.DEBUG) + .tcpConfig( + BootstrapConfig + .TcpConfig + .builder() + .port(8888) + .username("smqtt") + .password("smqtt") + .build()) + .httpConfig( + BootstrapConfig + .HttpConfig + .builder() + .enable(true) + .accessLog(true) + .build()) + .clusterConfig( + BootstrapConfig. + ClusterConfig + .builder() + .enable(true) + .namespace("smqtt") + .node("node-1") .port(7773) - .nodeName("node-2") - .clusterUrl("127.0.0.1:7771,127.0.0.1:7772") - .build() - ) - .started(bootstrap->{}) - .build() - .start().block(); + .url("127.0.0.1:7771,127.0.0.1:7772"). + build()) + .build() + .start().block(); ``` ## jar方式 @@ -274,12 +283,19 @@ curl -H "Content-Type: application/json" -X POST -d '{"topic": "test/teus", "qos - main启动 - 设置httpOptions && enableAdmin = true - + 1. 初始化BootstrapConfig.HttpConfig对象 ``` - Bootstrap.httpOptions(Bootstrap.HttpOptions.builder().enableAdmin(true).ssl(false).accessLog(true).build()) - + BootstrapConfig + .HttpConfig + .builder() + .enable(true) + .accessLog(true) + .build() ``` + 2. 设置到Bootstrap中 + ``` + Bootstrap.builder().httpConfig(你的HttpConfig); + ``` - jar / docker 启动 设置config.yaml diff --git a/config.yaml b/config.yaml index 518ec508a71a4b5cb49c93e446bbcca35a89828b..3200e3f23ebcf56782a1ca388c842465bc90811d 100644 --- a/config.yaml +++ b/config.yaml @@ -72,22 +72,22 @@ smqtt: master: mymaster nodes: 127.0.0.1:26379,127.0.0.1:26379,127.0.0.1:26379 - rules: + rules: # 规则引擎相关配置 - ruleName: 过滤 - chain: - - ruleType: PREDICATE - script: topic.equals("test/test") - - ruleType: KAFKA + chain: # 规则链 + - ruleType: PREDICATE # 条件过滤 + script: topic.equals("test/test") #脚本 + - ruleType: KAFKA #转发到kafka script: '{"topic":"${topic}","msg":"${msg.test}","qos":${qos}}' - sources: - - source: KAFKA + sources: # 配置数据源sources + - source: KAFKA # kafka配置 sourceName: kafka sourceAttributes: topic: testTopic bootstrap.servers: 172.16.63.50:9092 key.serializer: org.apache.kafka.common.serialization.StringSerializer value.serializer: org.apache.kafka.common.serialization.StringSerializer - - source: ROCKET_MQ + - source: ROCKET_MQ # rocket mq配置 sourceName: rocketmq sourceAttributes: topic: testTopic