From c8c4f3a0d2a5c8f0df039ee8dcf98800e3d472f6 Mon Sep 17 00:00:00 2001 From: Tadayoshi Sato Date: Wed, 15 Nov 2023 15:55:18 +0900 Subject: [PATCH] fix(camel): debug breakpoint suspension doesn't work with Camel v4 Fix #666 --- .../hawtio/src/plugins/camel/camel-service.ts | 25 +++++++++++++++++++ .../src/plugins/camel/debug/debug-service.ts | 10 ++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/hawtio/src/plugins/camel/camel-service.ts b/packages/hawtio/src/plugins/camel/camel-service.ts index dd634936..4bf7b2e7 100644 --- a/packages/hawtio/src/plugins/camel/camel-service.ts +++ b/packages/hawtio/src/plugins/camel/camel-service.ts @@ -264,6 +264,31 @@ export function getBreakpointsOperation(node: MBeanNode): string { return isCamelVersionEQGT(node, 4, 0) ? 'breakpoints' : 'getBreakpoints' } +/** + * Returns the name of operation for getting all the suspended breakpoint IDs on + * the BacklogDebugger MBean. The operation name differs between Camel v3 and v4. + */ +export function getSuspendedBreakpointNodeIdsOperation(node: MBeanNode): string { + return isCamelVersionEQGT(node, 4, 0) ? 'suspendedBreakpointNodeIds' : 'getSuspendedBreakpointNodeIds' +} + +/** + * Executes the operation for dumping traced messages as XML on the BacklogDebugger + * MBean. The operation name differs between Camel v3 and v4. + */ +export function dumpTracedMessagesAsXml(node: MBeanNode, debugMBean: string, breakpointId: string): Promise { + if (isCamelVersionEQGT(node, 4, 0)) { + return jolokiaService.execute(debugMBean, 'dumpTracedMessagesAsXml(java.lang.String,boolean)', [ + breakpointId, + false, + ]) as Promise + } else { + return jolokiaService.execute(debugMBean, 'dumpTracedMessagesAsXml(java.lang.String)', [ + breakpointId, + ]) as Promise + } +} + export function canGetBreakpoints(node: MBeanNode): boolean { if (!isRouteNode(node)) return false diff --git a/packages/hawtio/src/plugins/camel/debug/debug-service.ts b/packages/hawtio/src/plugins/camel/debug/debug-service.ts index 89093c21..76aaefb2 100644 --- a/packages/hawtio/src/plugins/camel/debug/debug-service.ts +++ b/packages/hawtio/src/plugins/camel/debug/debug-service.ts @@ -142,7 +142,10 @@ class DebugService { const db = this.getDebugBean(node) if (!db || !db.objectName) return [] - const result = await jolokiaService.execute(db.objectName, 'getSuspendedBreakpointNodeIds') + const result = await jolokiaService.execute( + db.objectName, + camelService.getSuspendedBreakpointNodeIdsOperation(node), + ) return result as string[] } @@ -168,10 +171,7 @@ class DebugService { const db = this.getDebugBean(node) if (!db || !db.objectName) return '' - const result = await jolokiaService.execute(db.objectName, 'dumpTracedMessagesAsXml(java.lang.String)', [ - breakpointId, - ]) - return result as string + return await camelService.dumpTracedMessagesAsXml(node, db.objectName, breakpointId) } async resume(node: MBeanNode): Promise {