@@ -716,6 +716,52 @@ public void run(Timeout timeout) throws Exception {
716
716
}
717
717
}
718
718
719
+ /**
720
+ * When SDK start, the initial subscribed topics information set by user will be sent to the
721
+ * node. User can update subscribed topics again by following steps: 1. Set the topics you want
722
+ * to subscribe to again Service service // Servcie object Set<String> topics // topics that
723
+ * subscribe again service.setTopics(topics) 2. send update topics message to all nodes
724
+ * service.updateTopicsToNode();
725
+ */
726
+ public void updateTopicsToNode () {
727
+
728
+ logger .info (" updateTopicToNode, groupId: {}, topics: {}" , groupId , getTopics ());
729
+
730
+ // select send node
731
+ ChannelConnections channelConnections =
732
+ allChannelConnections
733
+ .getAllChannelConnections ()
734
+ .stream ()
735
+ .filter (x -> x .getGroupId () == groupId )
736
+ .findFirst ()
737
+ .get ();
738
+
739
+ if (Objects .isNull (channelConnections )) {
740
+ throw new IllegalArgumentException (
741
+ " No group configuration was found, groupId: " + groupId );
742
+ }
743
+
744
+ ConnectionCallback callback = (ConnectionCallback ) channelConnections .getCallback ();
745
+ if (Objects .isNull (callback )) {
746
+ throw new IllegalArgumentException (
747
+ " No callback was found for ChannelConnections, service is not initialized" );
748
+ }
749
+ callback .setTopics (getTopics ());
750
+
751
+ /** send update topic message to all connected nodes */
752
+ Map <String , ChannelHandlerContext > networkConnections =
753
+ channelConnections .getNetworkConnections ();
754
+ for (ChannelHandlerContext ctx : networkConnections .values ()) {
755
+ if (Objects .nonNull (ctx ) && ChannelHandlerContextHelper .isChannelAvailable (ctx )) {
756
+ try {
757
+ callback .sendUpdateTopicMessage (ctx );
758
+ } catch (Exception e ) {
759
+ logger .debug (" e: " , e );
760
+ }
761
+ }
762
+ }
763
+ }
764
+
719
765
public void asyncMulticastChannelMessageForVerifyTopic (ChannelRequest request ) {
720
766
String toTopic = request .getToTopic ();
721
767
request .setToTopic (getNeedVerifyTopics (toTopic ));
@@ -1133,7 +1179,7 @@ public void onReceiveChannelMessage2(ChannelHandlerContext ctx, ChannelMessage2
1133
1179
1134
1180
push .setSeq (message .getSeq ());
1135
1181
push .setMessageID (message .getSeq ());
1136
- logger .info ("msg:{}" , Arrays .toString (message .getData ()));
1182
+ logger .debug ("msg:{}" , Arrays .toString (message .getData ()));
1137
1183
push .setContent (message .getData ());
1138
1184
pushCallback .onPush (push );
1139
1185
} else {
@@ -1145,7 +1191,7 @@ public void onReceiveChannelMessage2(ChannelHandlerContext ctx, ChannelMessage2
1145
1191
}
1146
1192
1147
1193
} else if (message .getType () == ChannelMessageType .AMOP_RESPONSE .getType ()) {
1148
- logger .info ("channel message:{}" , message .getSeq ());
1194
+ logger .debug ("channel message:{}" , message .getSeq ());
1149
1195
if (callback != null ) {
1150
1196
logger .debug ("found callback response" );
1151
1197
0 commit comments