Skip to content

Commit 4f257aa

Browse files
committed
Merge branch 'v1.0' into v1.2
2 parents 0d3a8d7 + 0d146c7 commit 4f257aa

File tree

4 files changed

+5
-45
lines changed

4 files changed

+5
-45
lines changed

src/main/java/com/jun/mqttx/broker/handler/PublishHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,6 @@ private void publish0(ClientSub clientSub, PubMsg pubMsg, boolean isClusterMessa
404404
public void handleRetainMsg(PubMsg pubMsg) {
405405
byte[] payload = pubMsg.getPayload();
406406
String topic = pubMsg.getTopic();
407-
int qos = pubMsg.getQoS();
408407

409408
// with issue https://github.com/Amazingwujun/mqttx/issues/14 And PR
410409
// https://github.com/Amazingwujun/mqttx/pull/15
@@ -415,15 +414,16 @@ public void handleRetainMsg(PubMsg pubMsg) {
415414
// no retained message for that topic [MQTT-3.3.1-7].
416415
// [MQTT-3.3.1-7] 当 broker 收到 qos 为 0 并且 RETAIN = 1 的消息 必须抛弃该主题保留
417416
// 之前的消息(注意:是 retained 消息), 同时 broker 可以选择保留或抛弃当前的消息,MQTTX
418-
// 的选择是抛弃.
417+
// 的选择是保留.
418+
419419
// A PUBLISH Packet with a RETAIN flag set to 1 and a payload containing zero
420420
// bytes will be processed as normal by the Server and sent to Clients with a
421421
// subscription matching the topic name. Additionally any existing retained
422422
// message with the same topic name MUST be removed and any future subscribers
423423
// for the topic will not receive a retained message [MQTT-3.3.1-10].
424424
// [MQTT-3.3.1-10] 注意 [Additionally] 内容, broker 收到 retain 消息载荷(payload)
425425
// 为空时,broker 必须移除 topic 关联的 retained 消息.
426-
if (MqttQoS.AT_MOST_ONCE.value() == qos || ObjectUtils.isEmpty(payload)) {
426+
if (ObjectUtils.isEmpty(payload)) {
427427
retainMessageService.remove(topic);
428428
return;
429429
}

src/main/java/com/jun/mqttx/service/ISubscriptionService.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,6 @@ public interface ISubscriptionService {
6363
*/
6464
void clearClientSubscriptions(String clientId, boolean cleanSession);
6565

66-
/**
67-
* 移除指定 topic
68-
*
69-
* @param topic 主题
70-
*/
71-
void removeTopic(String topic);
72-
7366
/**
7467
* 移除未包含在 authorizedSub 集合中的客户端订阅
7568
*
@@ -107,4 +100,4 @@ public interface ISubscriptionService {
107100
* @param clientId 客户 id
108101
*/
109102
void clearClientSysSub(String clientId);
110-
}
103+
}

src/main/java/com/jun/mqttx/service/impl/DefaultSubscriptionServiceImpl.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -253,39 +253,6 @@ public void clearClientSubscriptions(String clientId, boolean cleanSession) {
253253
}
254254
}
255255

256-
/**
257-
* 移除 topic
258-
*
259-
* @param topic 主题
260-
*/
261-
@Override
262-
public void removeTopic(String topic) {
263-
inMemTopics.remove(topic);
264-
Optional.ofNullable(inMemTopicClientsMap.remove(topic))
265-
.ifPresent(e -> e.forEach(
266-
clientSub -> Optional.
267-
ofNullable(inMemClientTopicsMap.get(clientSub.getClientId()))
268-
.ifPresent(t -> t.remove(topic)))
269-
);
270-
stringRedisTemplate.opsForSet().remove(topicSetKey, topic);
271-
272-
// 抓取订阅主题的全部 clientId, 通过 clientId 移除所有其订阅的 topic
273-
Set<Object> keys = stringRedisTemplate.opsForHash().keys(topicPrefix + topic);
274-
keys.forEach(t -> stringRedisTemplate.opsForSet().remove(clientTopicsPrefix + t, topic));
275-
stringRedisTemplate.delete(topicPrefix + topic);
276-
277-
if (enableInnerCache) {
278-
removeTopicWithCache(topic);
279-
280-
// 集群广播
281-
if (enableCluster) {
282-
ClientSubOrUnsubMsg clientSubOrUnsubMsg = new ClientSubOrUnsubMsg(null, 0, topic, false, null, DEL_TOPIC);
283-
InternalMessage<ClientSubOrUnsubMsg> im = new InternalMessage<>(clientSubOrUnsubMsg, System.currentTimeMillis(), brokerId);
284-
internalMessagePublishService.publish(im, InternalMessageEnum.SUB_UNSUB.getChannel());
285-
}
286-
}
287-
}
288-
289256
@Override
290257
public void clearUnAuthorizedClientSub(String clientId, List<String> authorizedSub) {
291258
List<String> collect = inDiskTopics

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
spring:
44
application:
5-
name: @broker.name@
5+
name: @project.name@
66
profiles:
77
# 该配置决定使用 application-dev.yml 还是 application-prod.yml 作为附加配置文件
88
active: @profile@

0 commit comments

Comments
 (0)