Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JBang - run in JVM debug mode so you can do JVM remote debugging #116

Open
davsclaus opened this issue Nov 22, 2021 · 9 comments
Open

JBang - run in JVM debug mode so you can do JVM remote debugging #116

davsclaus opened this issue Nov 22, 2021 · 9 comments
Labels

Comments

@davsclaus
Copy link
Contributor

We should find out if we can launch jbang in JVM debug mode (there are some JVM flags you need to turn on, to make it debug mode on port 5005, and suspend=y etc.

And if so we should find out if we can make VSCode detect this and be able to debug the Camel code. Not sure how easy it is for it to know which JARs to have on its project and so on.

But its also a more general problem with jbang, so we can talk to Max about this.

@mgubaidullin
Copy link
Contributor

I think this feature outside Karavan for now.
If we have yaml route debugger in VSCode perhaps we could try to visualize it on the diagram.

@apupier
Copy link
Contributor

apupier commented Apr 15, 2022

If we have yaml route debugger in VSCode perhaps we could try to visualize it on the diagram.

The Camel route debugger for yaml dsl is now available:
https://www.youtube.com/watch?v=GEQHexFKWcQ&list=PLU-T8l-XOWOPjrXPojx2WDSegigcNzKs4&index=4

Given that with latest version, JMX is supported, this other video can be interesting https://www.youtube.com/watch?v=YSr-FccRgms&list=PLU-T8l-XOWOPjrXPojx2WDSegigcNzKs4&index=2&t=37s

That said, the Camel route debugger for yaml dsl is a different kind of debugging than the JVM debug. The JVM debug is also possible to attach to a running process
Screenshot from 2022-04-15 14-41-51

@apupier
Copy link
Contributor

apupier commented Apr 15, 2022

documentation for jbang in debug mode https://www.jbang.dev/documentation/guide/latest/debugging.html
so basically would mean to add the --debug and it will automatically open debug port 4004

@mgubaidullin
Copy link
Contributor

  1. Karavan works as VS Code extension and web app (standalone and in kubernetes). Debug should somehow works in both.
  2. If I understand correctly Debug uses line number to be known. In that case we need first to make a new yaml-to-integration parser because the current one (js-yaml) does not provide this info.

@davsclaus
Copy link
Contributor Author

Yesterday I tried the vscode camel debugger and with a bit of configuring those config files then made it work. I could debug camel jbang for yaml files.

I think in .java then vscode would set the breakpoint as a java breakpoint so that was not possible.

Also I added camel-debug always so its included
apache/camel@ae29979

@apupier
Copy link
Contributor

apupier commented Apr 15, 2022

I think in .java then vscode would set the breakpoint as a java breakpoint so that was not possible.

Unless I misunderstood the use case, it is working (cannot combine the task and the launch config, shoudl require extra configuration):
CamelDebuggerWithJavaDSlLaunchedthroughJBang

Also I added camel-debug always so its included
apache/camel@ae29979

camel-jbang cannot be used in production?

@apupier
Copy link
Contributor

apupier commented Apr 20, 2022

cannot combine the task and the launch config, shoudl require extra configuration

managed to have teh single-click working.

.vscode/tasks.json:

{
	// See https://go.microsoft.com/fwlink/?LinkId=733558
	// for the documentation about the tasks.json format
	"version": "2.0.0",
	"tasks": [
		{
			"label": "Start Camel application in debug with Jbang",
			"type": "shell",
			"command": "jbang",
			"args": [
				"-Dcamel.jbang.version=3.16.0",
				"camel@apache/camel",
				"run",
				"${relativeFile}",
				"--max-messages=100",
				"--logging-level=info",
				"--reload",
				"--dep=org.apache.camel:camel-debug"
			],
			"group": "none",
			"isBackground": true,
			"problemMatcher": { // Problem matcher is mandatory to avoid a dialog warning on each launch but cannot find a good way to configure it
				"owner": "camel",
				"pattern": {
					"regexp": "^.*$"
				},
				"severity": "error",
				"source": "maven",
				"background": {
					"activeOnStart": true,
					"beginsPattern": "^.*$",
					"endsPattern": "^.*JMX Connector thread started and listening at.*$"
				}
			},
			"presentation": {
				"reveal": "always"
			}
		}
	]
}

.vscode/launch.json:

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Run with Camel Debugger",
			"type": "apache.camel",
			"request": "attach",
			"preLaunchTask": "Start Camel application in debug with Jbang" // This must match the label provided as task
		}
	]
}

@mgubaidullin
Copy link
Contributor

Will be implemented as a part of #151

@apupier
Copy link
Contributor

apupier commented Sep 15, 2022

Will be implemented as a part of #151

Java debugging and Camel debugging are 2 different things. Both functionnaly and technically behind the scenes. I think both issues should stay opened as they can be handled completely independently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants