fuweng11 commented on code in PR #8357:
URL: https://github.com/apache/inlong/pull/8357#discussion_r1246440999
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/queue/tubemq/TubeMQResourceOperator.java:
##########
@@ -108,4 +112,25 @@ public void deleteQueueForStream(InlongGroupInfo
groupInfo, InlongStreamInfo str
// currently, not support delete tubemq resource for stream
}
+ public List<BriefMQMessage> queryLastestMessage(InlongGroupInfo groupInfo,
InlongStreamInfo streamInfo,
+ Integer messageCount) {
+ Preconditions.expectNotNull(groupInfo, "inlong group info cannot be
null");
+
+ String groupId = groupInfo.getInlongGroupId();
+ List<BriefMQMessage> briefMQMessages = new ArrayList<>();
+
+ try {
+ // 1. create tubemq topic
Review Comment:
Done.
##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/resource/queue/tubemq/TubeMQOperator.java:
##########
@@ -248,4 +265,60 @@ private void createConsumerGroupOpt(String masterUrl,
String topicName, String c
}
}
+ /**
+ * Query topic message for the given tubemq cluster.
+ */
+ public List<BriefMQMessage> queryLastMessage(TubeClusterInfo tubeCluster,
String topicName,
+ Integer messageCount, InlongStreamInfo streamInfo) {
+ LOGGER.info("begin to query message for topic {}", topicName);
+ String masterUrl = tubeCluster.getMasterWebUrl();
+ TubeBrokerInfo brokerView = this.getBrokerInfo(masterUrl);
+ String brokerUrl = brokerView.getOneWorkBrokerIp();
+
+ List<BriefMQMessage> messageList = new ArrayList<>();
+ try {
+ String url =
+ "http://" + brokerUrl + QUERY_LAST_MESSAGE_PATH +
TOPIC_NAME + topicName + MSG_COUNT + messageCount;
+
+ if (StringUtils.isEmpty(brokerUrl) ||
StringUtils.isEmpty(topicName)) {
+ throw new BusinessException("tubemq master url or tubemq topic
cannot be null");
+ }
+
+ if (!this.isTopicExist(masterUrl, topicName)) {
+ LOGGER.error("tubemq topic {} not exists in {}, skip to
create", topicName, masterUrl);
+ throw new BusinessException("tubemq master url or tubemq topic
cannot be null");
+ }
+
+ TubeMessageResponse response = HttpUtils.request(restTemplate,
url, HttpMethod.GET,
+ null, new HttpHeaders(), TubeMessageResponse.class);
+ if (response.getErrCode() != SUCCESS_CODE) {
+ String msg = String.format("failed to query message for topic
%s, error: %s",
+ topicName, response.getErrMsg());
+ LOGGER.error(msg + " in {} for broker {}", masterUrl,
brokerUrl);
+ throw new BusinessException(msg);
+ }
+ int index = 0;
+ for (TubeDataInfo tubeDataInfo : response.getDataSet()) {
+ Map<String, String> map = new HashMap<>();
+ for (String kv :
tubeDataInfo.getAttr().split(InlongConstants.COMMA)) {
+ map.put(kv.split("=")[0], kv.split("=")[1]);
Review Comment:
Done.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]