forked from apache/rocketmq-externals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ISSUE apache#669] Support RocketMQ as storage of mqtt broker (apache…
…#687) * Config refactor, add some rocketmq config * Add rmq publish producer * Fix NPE start with memory mode, remove useless dependency * Non-standard mqtt request return directly * Add rmq subscribe consumer and related pull task, complete mqtt SUBSCRIBE and UNSUBSCRIBE protcol * Fix subTopic not remove when disconnect * Fix connection management, fix consume delay to make pull task to queue level * Fix ut not pass when root topic removed from subsription * Fix integration test not pass when not use rmq subscribe consumer Co-authored-by: zhangxu16 <[email protected]>
- Loading branch information
1 parent
7677497
commit 1a88e51
Showing
24 changed files
with
940 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
...etmq-iot-bridge/src/main/java/org/apache/rocketmq/iot/common/config/MqttBridgeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.rocketmq.iot.common.config; | ||
|
||
import java.util.Properties; | ||
|
||
import static org.apache.rocketmq.iot.common.configuration.MQTTBridgeConfiguration.*; | ||
|
||
public class MqttBridgeConfig { | ||
private Properties properties; | ||
|
||
private String brokerHost; | ||
private int brokerPort; | ||
private int bossGroupThreadNum; | ||
private int workerGroupThreadNum; | ||
private int socketBacklogSize; | ||
|
||
private boolean enableRocketMQStore; | ||
private String rmqNamesrvAddr; | ||
private String rmqProductGroup; | ||
private String rmqConsumerGroup; | ||
private int rmqConsumerPullNums; | ||
private String rmqAccessKey; | ||
private String rmqSecretKey; | ||
|
||
public MqttBridgeConfig() { | ||
initConfig(); | ||
} | ||
|
||
public MqttBridgeConfig(Properties properties) { | ||
this.properties = properties; | ||
} | ||
|
||
public void initConfig() { | ||
this.brokerHost = System.getProperty(MQTT_BROKER_HOST, MQTT_BROKER_HOST_DEFAULT); | ||
this.brokerPort = Integer.parseInt(System.getProperty(MQTT_BROKER_PORT, MQTT_BROKER_PORT_DEFAULT)); | ||
|
||
this.bossGroupThreadNum = Integer.parseInt(System.getProperty(MQTT_SERVER_BOSS_GROUP_THREAD_NUM, | ||
MQTT_SERVER_BOSS_GROUP_THREAD_NUM_DEFAULT)); | ||
this.workerGroupThreadNum = Integer.parseInt(System.getProperty(MQTT_SERVER_WORKER_GROUP_THREAD_NUM, | ||
MQTT_SERVER_WORKER_GROUP_THREAD_NUM_DEFAULT)); | ||
this.socketBacklogSize = Integer.parseInt(System.getProperty(MQTT_SERVER_SOCKET_BACKLOG_SIZE, | ||
MQTT_SERVER_SOCKET_BACKLOG_SIZE_DEFAULT)); | ||
|
||
this.enableRocketMQStore = Boolean.parseBoolean(System.getProperty(MQTT_ROCKETMQ_STORE_ENABLED, MQTT_ROCKETMQ_STORE_ENABLED_DEFAULT)); | ||
if (enableRocketMQStore) { | ||
this.rmqNamesrvAddr = System.getProperty(MQTT_ROCKETMQ_NAMESRVADDR, MQTT_ROCKETMQ_NAMESRVADDR_DEFAULT); | ||
this.rmqProductGroup = System.getProperty(MQTT_ROCKETMQ_PRODUCER_GROUP, MQTT_ROCKETMQ_PRODUCER_GROUP_DEFAULT); | ||
this.rmqConsumerGroup = System.getProperty(MQTT_ROCKETMQ_CONSUMER_GROUP, MQTT_ROCKETMQ_CONSUMER_GROUP_DEFAULT); | ||
this.rmqConsumerPullNums = Integer.parseInt(System.getProperty(MQTT_ROKECTMQ_CONSUMER_PULL_NUMS, | ||
MQTT_ROKECTMQ_CONSUMER_PULL_NUMS_DEFAULT)); | ||
|
||
this.rmqAccessKey = System.getProperty(MQTT_ROCKETMQ_ACCESSKEY, MQTT_ROCKETMQ_ACCESSKEY_DEFAULT); | ||
this.rmqSecretKey = System.getProperty(MQTT_ROCKETMQ_SECRETKEY, MQTT_ROCKETMQ_SECRETKEY_DEFAULT); | ||
} | ||
|
||
} | ||
|
||
public String getBrokerHost() { | ||
return brokerHost; | ||
} | ||
|
||
public int getBrokerPort() { | ||
return brokerPort; | ||
} | ||
|
||
public int getBossGroupThreadNum() { | ||
return bossGroupThreadNum; | ||
} | ||
|
||
public int getWorkerGroupThreadNum() { | ||
return workerGroupThreadNum; | ||
} | ||
|
||
public int getSocketBacklogSize() { | ||
return socketBacklogSize; | ||
} | ||
|
||
public boolean isEnableRocketMQStore() { | ||
return enableRocketMQStore; | ||
} | ||
|
||
public String getRmqAccessKey() { | ||
return rmqAccessKey; | ||
} | ||
|
||
public String getRmqSecretKey() { | ||
return rmqSecretKey; | ||
} | ||
|
||
public String getRmqNamesrvAddr() { | ||
return rmqNamesrvAddr; | ||
} | ||
|
||
public String getRmqProductGroup() { | ||
return rmqProductGroup; | ||
} | ||
|
||
public String getRmqConsumerGroup() { | ||
return rmqConsumerGroup; | ||
} | ||
|
||
public int getRmqConsumerPullNums() { | ||
return rmqConsumerPullNums; | ||
} | ||
|
||
@Override public String toString() { | ||
return "MqttBridgeConfig{" + | ||
"brokerHost='" + brokerHost + '\'' + | ||
", brokerPort=" + brokerPort + | ||
", bossGroupThreadNum=" + bossGroupThreadNum + | ||
", workerGroupThreadNum=" + workerGroupThreadNum + | ||
", socketBacklogSize=" + socketBacklogSize + | ||
", enableRocketMQStore=" + enableRocketMQStore + | ||
", rmqNamesrvAddr='" + rmqNamesrvAddr + '\'' + | ||
", rmqProductGroup='" + rmqProductGroup + '\'' + | ||
", rmqConsumerGroup='" + rmqConsumerGroup + '\'' + | ||
", rmqConsumerPullNums='" + rmqConsumerPullNums + '\'' + | ||
", rmqAccessKey='" + rmqAccessKey + '\'' + | ||
", rmqSecretKey='" + rmqSecretKey + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.