From 1166083920dde76f315ce924d03df4e53cf5ee86 Mon Sep 17 00:00:00 2001 From: GChuf Date: Sun, 2 Nov 2025 13:28:25 +0100 Subject: [PATCH 1/2] ARTEMIS-5737: Fix duplicated jolokia calls on web console's status page --- .../src/status/Status.tsx | 89 ++++++++++--------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/status/Status.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/status/Status.tsx index 024c39d..cdbc021 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/status/Status.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/status/Status.tsx @@ -55,57 +55,62 @@ export const Status: React.FunctionComponent = () => { const [showAttributesDialog, setShowAttributesDialog] = useState(false); const [showOperationsDialog, setShowOperationsDialog] = useState(false); - useEffect(() => { - const getBrokerInfo = async () => { - artemisService.getBrokerInfo() - .then((brokerInfo) => { - setBrokerInfo(brokerInfo ?? undefined) - }) - .catch((error: string) => { - eventService.notify({ - type: 'warning', - message: error, - }) - }); - } - const getAcceptors = async () => { - artemisService.createAcceptors() - .then((acceptors) => { - setAcceptors(acceptors) + const getBrokerInfo = async () => { + artemisService.getBrokerInfo() + .then((brokerInfo) => { + setBrokerInfo(brokerInfo ?? undefined) + }) + .catch((error: string) => { + eventService.notify({ + type: 'warning', + message: error, }) - .catch((error: string) => { - eventService.notify({ - type: 'warning', - message: error, - }) - }); - } - if (!brokerInfo) { - getBrokerInfo(); - } + }); + } - if (!acceptors) { - getAcceptors(); - } + const getAcceptors = async () => { + artemisService.createAcceptors() + .then((acceptors) => { + setAcceptors(acceptors) + }) + .catch((error: string) => { + eventService.notify({ + type: 'warning', + message: error, + }) + }); + } - if (!clusterConnections) { - artemisService.createClusterConnections() - .then((clusterConnections) => { - setClusterConnections(clusterConnections) + const getClusterConnections = async () => { + artemisService.createClusterConnections() + .then((clusterConnections) => { + setClusterConnections(clusterConnections) + }) + .catch((error: string) => { + eventService.notify({ + type: 'warning', + message: error, }) - .catch((error: string) => { - eventService.notify({ - type: 'warning', - message: error, - }) - }); - } + }); + } + + useEffect(() => { + // run only once at the beginning + getBrokerInfo(); + + getAcceptors(); + + getClusterConnections(); const timer = setInterval(getBrokerInfo, 5000) return () => clearInterval(timer) - }, [brokerInfo, acceptors, clusterConnections]) + }, []) + + useEffect(() => { + // update frontend when brokerInfo, acceptors, or clusterConnections change + }, [brokerInfo, acceptors, clusterConnections]); const [isBrokerInfoOpen, setIsBrokerInfoOpen] = useState(false); From a1cc4cc8ac0c93282b1a1541b7eb49b3208ae85d Mon Sep 17 00:00:00 2001 From: GChuf Date: Sun, 2 Nov 2025 14:49:58 +0100 Subject: [PATCH 2/2] ARTEMIS-5737 Implement getBrokerName function for ArtemisHeader --- .../artemis-console-plugin/src/ArtemisHeader.tsx | 9 ++++----- .../artemis-console-plugin/src/artemis-service.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/ArtemisHeader.tsx b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/ArtemisHeader.tsx index ab027ae..37cc9b0 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/ArtemisHeader.tsx +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/ArtemisHeader.tsx @@ -25,10 +25,9 @@ export const ArtemisHeader: React.FunctionComponent = () => { const [ brokerHeader, setBrokerHeader] = useState('') useEffect(() => { - - artemisService.getBrokerInfo() - .then((brokerInfo) => { - setBrokerHeader(brokerInfo ? brokerInfo.name : ''); + artemisService.getBrokerName() + .then((brokerName) => { + setBrokerHeader(brokerName ? brokerName : ''); }) .catch((error: string) => { eventService.notify({ @@ -36,7 +35,7 @@ export const ArtemisHeader: React.FunctionComponent = () => { message: error, }) }); - }) + },[]) return ( <>{'Broker ('}{brokerHeader}{')'} diff --git a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts index b27307d..ea5edfd 100644 --- a/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts +++ b/artemis-console-extension/artemis-extension/packages/artemis-console-plugin/src/artemis-service.ts @@ -175,6 +175,15 @@ class ArtemisService { return search && search[0] ? search[0] : ""; } + async getBrokerName(): Promise { + const brokerObjectName = await this.brokerObjectName; + const response = await jolokiaService.readAttribute(brokerObjectName, "Name"); + if (response) { + return response as string; + } + return null; + } + async getBrokerInfo(): Promise { return new Promise(async (resolve, reject) => { const brokerObjectName = await this.brokerObjectName; @@ -218,7 +227,6 @@ class ArtemisService { }); } - async createBrokerTopology(maxAddresses: number, addressFilter: string): Promise { return new Promise(async (resolve, reject) => { try {