diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c
index a40ee07..ca8b0fe 100644
--- a/src/sp/protocol/pubsub0/sub.c
+++ b/src/sp/protocol/pubsub0/sub.c
@@ -300,14 +300,60 @@ sub0_pipe_close(void *arg)
 	nni_aio_close(&p->aio_recv);
 }
 
+#if 1 //add by xpzhao mqtt topic support
+extern int mosquitto_topic_matches_sub(const char *sub, const char *topic, bool *result);
+#endif
 static bool
 sub0_matches(sub0_ctx *ctx, uint8_t *body, size_t len)
 {
 	sub0_topic *topic;
 
+	#if 1 //add by xpzhao mqtt topic support
+	int i = 0;
+	char t[128] = {0};
+	char t2[128] = {0};
+	for (i = 0; i < len; i++)
+	{
+		if (body[i] == '|')
+		{
+			break;
+		}
+	}
+	memcpy(t, body, i);
+	t[i] = 0;
+	#endif
+
 	// This is a naive and trivial matcher.  Replace with a real
 	// patricia trie later.
 	NNI_LIST_FOREACH (&ctx->topics, topic) {
+		#if 1 //add by xpzhao mqtt topic support
+		if (i == len)
+		{
+			// 没有|则按照之前的memcmp进行匹配
+			if (len < topic->len) {
+				continue;
+			}
+			if ((topic->len == 0) ||
+				(memcmp(topic->buf, body, topic->len) == 0)) {
+				return (true);
+			}
+		}
+		else
+		{
+			bool ret;
+			if (topic->len == 0)
+			{
+				return (true);
+			}
+			memcpy(t2, topic->buf, topic->len);
+			t2[topic->len] = 0;
+			mosquitto_topic_matches_sub(t2, t, (bool *)&ret);
+			if (ret)
+			{
+				return ret;
+			}
+		}
+		#else
 		if (len < topic->len) {
 			continue;
 		}
@@ -315,6 +361,7 @@ sub0_matches(sub0_ctx *ctx, uint8_t *body, size_t len)
 		    (memcmp(topic->buf, body, topic->len) == 0)) {
 			return (true);
 		}
+		#endif
 	}
 	return (false);
 }
