mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
add containsTopic method
This commit is contained in:
+7
@@ -31,6 +31,13 @@ public interface MessageExchangeService {
|
||||
|
||||
void subscribe(Topic topic, int timeout, MessageHandler messageHandler) throws MessageExchangeException;
|
||||
|
||||
/**
|
||||
* Whether exists the specify topic
|
||||
* @param topic
|
||||
* @return
|
||||
*/
|
||||
boolean containsTopic(Topic topic);
|
||||
|
||||
interface MessageHandler {
|
||||
/**
|
||||
* handle message
|
||||
|
||||
+5
@@ -101,6 +101,11 @@ public class MessageExchangeServiceImpl implements MessageExchangeService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsTopic(Topic topic) {
|
||||
return topicMap.containsKey(topic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushMessage(Topic topic, byte[] messageBytes) throws MessageExchangeException {
|
||||
TopicData topicData = topicMap.get(topic);
|
||||
|
||||
+5
@@ -79,6 +79,11 @@ public class RedisMessageExchangeServiceImpl implements MessageExchangeService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsTopic(Topic topic) {
|
||||
return redisTemplate.hasKey(topic.getTopic()).block();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushMessage(Topic topic, byte[] messageBytes) throws MessageExchangeException {
|
||||
String key = topic.getTopic();
|
||||
|
||||
Reference in New Issue
Block a user