MCPcopy Create free account
hub / github.com/e2wugui/zeze / subscribe

Method subscribe

ZezeJava/ZezeJava/src/main/java/Zeze/MQ/MQAgent.java:41–62  ·  view source on GitHub ↗
(String topic, long sessionId, MQConsumer consumer, HashSet<Connector> managers)

Source from the content-addressed store, hash-verified

39 }
40
41 public void subscribe(String topic, long sessionId, MQConsumer consumer, HashSet<Connector> managers) {
42 if (consumers.putIfAbsent(sessionId, consumer) == null) {
43 var futures = new ArrayList<Subscribe>();
44 for (var manager : managers) {
45 var r = new Subscribe();
46 r.Argument.setTopic(topic);
47 r.Argument.setSessionId(sessionId);
48 r.SendForWait(manager.GetReadySocket());
49 futures.add(r);
50 }
51 // await all
52 for (var future : futures) {
53 assert future.getFuture() != null;
54 future.getFuture().await();
55 }
56 // check all result code
57 for (var future : futures) {
58 if (future.getResultCode() != 0)
59 throw new RuntimeException("subscribe consumer error=" + IModule.getErrorCode(future.getResultCode()));
60 }
61 }
62 }
63
64 public void unsubscribe(MQConsumer consumer, HashSet<Connector> managers) {
65 // unsubscribe all

Callers 2

MQConsumerMethod · 0.45

Calls 10

getErrorCodeMethod · 0.95
putIfAbsentMethod · 0.65
addMethod · 0.65
awaitMethod · 0.65
setTopicMethod · 0.45
setSessionIdMethod · 0.45
SendForWaitMethod · 0.45
GetReadySocketMethod · 0.45
getFutureMethod · 0.45
getResultCodeMethod · 0.45

Tested by

no test coverage detected