新建订阅
This commit is contained in:
@@ -20,4 +20,6 @@ public interface ConsumerService {
|
||||
ResponseData getConsumerMembers(String groupId);
|
||||
|
||||
ResponseData getConsumerDetail(String groupId);
|
||||
|
||||
ResponseData addSubscription(String groupId, String topic);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.apache.kafka.clients.admin.NewTopic;
|
||||
**/
|
||||
public interface TopicService {
|
||||
|
||||
ResponseData getTopicNameList();
|
||||
ResponseData getTopicNameList(boolean internal);
|
||||
|
||||
ResponseData getTopicList(String topic, TopicType type);
|
||||
|
||||
|
||||
@@ -98,4 +98,22 @@ public class ConsumerServiceImpl implements ConsumerService {
|
||||
});
|
||||
return ResponseData.create().data(res).success();
|
||||
}
|
||||
|
||||
@Override public ResponseData addSubscription(String groupId, String topic) {
|
||||
// check whether exist subscription relationship.
|
||||
Collection<ConsumerConsole.TopicPartitionConsumeInfo> consumerDetail = consumerConsole.getConsumerDetail(Collections.singleton(groupId));
|
||||
if (CollectionUtils.isNotEmpty(consumerDetail)) {
|
||||
List<ConsumerConsole.TopicPartitionConsumeInfo> collect = consumerDetail.stream()
|
||||
.filter(t -> t.getTopicPartition().topic().equals(topic)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect)) {
|
||||
return ResponseData.create().failed("The subscription exist.");
|
||||
}
|
||||
}
|
||||
|
||||
// consumer message and commit offset.
|
||||
|
||||
|
||||
// reset consume offset to 0.
|
||||
return ResponseData.create().success();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class TopicServiceImpl implements TopicService {
|
||||
@Autowired
|
||||
private TopicConsole topicConsole;
|
||||
|
||||
@Override public ResponseData getTopicNameList() {
|
||||
return ResponseData.create().data(topicConsole.getTopicNameList(true)).success();
|
||||
@Override public ResponseData getTopicNameList(boolean internal) {
|
||||
return ResponseData.create().data(topicConsole.getTopicNameList(internal)).success();
|
||||
}
|
||||
|
||||
@Override public ResponseData getTopicList(String topic, TopicType type) {
|
||||
|
||||
Reference in New Issue
Block a user