Skip to content

Commit

Permalink
fix(camel): debug breakpoint suspension doesn't work with Camel v4
Browse files Browse the repository at this point in the history
Fix #666
  • Loading branch information
tadayosi committed Nov 15, 2023
1 parent f53be4b commit 784261f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
25 changes: 25 additions & 0 deletions packages/hawtio/src/plugins/camel/camel-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
if (isCamelVersionEQGT(node, 4, 0)) {
return jolokiaService.execute(debugMBean, 'dumpTracedMessagesAsXml(java.lang.String,boolean)', [
breakpointId,
false,
]) as Promise<string>
} else {
return jolokiaService.execute(debugMBean, 'dumpTracedMessagesAsXml(java.lang.String)', [
breakpointId,
]) as Promise<string>
}
}

export function canGetBreakpoints(node: MBeanNode): boolean {
if (!isRouteNode(node)) return false

Expand Down
10 changes: 5 additions & 5 deletions packages/hawtio/src/plugins/camel/debug/debug-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
}

Expand All @@ -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<void> {
Expand Down

0 comments on commit 784261f

Please sign in to comment.