fix(pulsar-query): 修复pulsar查询topic存在没有使用admin url
This commit is contained in:
@@ -20,6 +20,8 @@ import org.apache.pulsar.common.policies.data.*;
|
|||||||
import org.eclipse.collections.api.factory.Lists;
|
import org.eclipse.collections.api.factory.Lists;
|
||||||
import org.eclipse.collections.api.list.ImmutableList;
|
import org.eclipse.collections.api.list.ImmutableList;
|
||||||
import org.eclipse.collections.api.list.MutableList;
|
import org.eclipse.collections.api.list.MutableList;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
|
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
|
||||||
@@ -51,6 +53,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("pulsar")
|
@RequestMapping("pulsar")
|
||||||
public class PulsarQueryApplication {
|
public class PulsarQueryApplication {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(PulsarQueryApplication.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(PulsarQueryApplication.class, args);
|
SpringApplication.run(PulsarQueryApplication.class, args);
|
||||||
}
|
}
|
||||||
@@ -276,8 +280,11 @@ public class PulsarQueryApplication {
|
|||||||
@Cacheable(value = "exists-topic", sync = true)
|
@Cacheable(value = "exists-topic", sync = true)
|
||||||
@GetMapping("exists_topic")
|
@GetMapping("exists_topic")
|
||||||
public Boolean existsTopic(@RequestParam("url") String url, @RequestParam("topic") String topic) throws PulsarClientException, PulsarAdminException {
|
public Boolean existsTopic(@RequestParam("url") String url, @RequestParam("topic") String topic) throws PulsarClientException, PulsarAdminException {
|
||||||
|
String name = name(url);
|
||||||
|
logger.info("Detected name: {}", name);
|
||||||
|
PulsarInfo info = getInfo(name);
|
||||||
try (PulsarAdmin admin = PulsarAdmin.builder()
|
try (PulsarAdmin admin = PulsarAdmin.builder()
|
||||||
.serviceHttpUrl(url)
|
.serviceHttpUrl(adminUrl(info))
|
||||||
.build()) {
|
.build()) {
|
||||||
List<String> tenants = admin.tenants().getTenants();
|
List<String> tenants = admin.tenants().getTenants();
|
||||||
for (String tenant : tenants) {
|
for (String tenant : tenants) {
|
||||||
|
|||||||
Reference in New Issue
Block a user