apupier commented on code in PR #822:
URL: https://github.com/apache/camel-website/pull/822#discussion_r848569026


##########
content/blog/2022/04/start-camel-application-with-camel-textual-debug-in-vscode/index.md:
##########
@@ -0,0 +1,129 @@
+---
+title: "Start a Camel Main application with Textual debug for Camel routes in 
VS Code with a single launch configuration"
+date: 2022-04-13
+authors: [apupier]
+categories: ["Tooling"]
+preview: "Start a Camel Main application with Textual debug for Camel routes 
in VS Code with a single launch configuration"
+---
+
+Textual debug for Camel routes allows to set breakpoints at Route definition.
+
+The Debug Adapter for Apache Camel latest release 0.1.1 [supports JMX 
connection](/blog/2022/04/camel-textual-debug-0.1.0/). It opens the possibility 
to start a Camel application with Camel textual route debugging activated in a 
single VS Code launch configuration. I thought it would be a five minutes 
effort but it was a several hours search to configure a not-yet-perfect 
solution. I hope that sharing the current state will save you few hours! Let's 
see the different configurations required to achieve it.
+
+# How to configure VS Code
+
+## Minimal Camel version
+
+Check that Camel 3.16+ is used.
+
+## camel-debug on classpath
+
+`camel-debug` must be on the classpath for the debug session. As it should not 
be used in production, a good way to achieve it is to use a Maven profile, for 
instance:
+
+```xml
+<profiles>
+        <profile>
+            <id>camel.debug</id>
+            <activation>
+                <property>
+                    <name>camel.debug</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.camel</groupId>
+                    <artifactId>camel-debug</artifactId>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+```
+
+## VS Code task to start application
+
+Next step consist in providing a VS Code task to start the Camel application 
with `camel-debug` on the classpath by using the `camel.debug` profile 
mentioned in previous point.
+
+In `.settings/tasks.json` (the file might need to be created), you need to add 
this kind of task:
+
+```json
+{
+       "version": "2.0.0",
+       "tasks": [
+               {
+                       "label": "Run Camel application with debug Profile",
+                       "type": "shell",
+                       "command": "mvn", // mvn binary of Maven must be 
available on command-line
+                       "args": [
+                               "camel:run",
+                               "-Pcamel.debug" // This depends on your 
project. The goal here is to have camel-debug on the classpath.
+                       ],
+                       "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": "^.*$"
+                               }
+                       },
+                       "presentation": {
+                               "reveal": "always"
+                       },
+                       "isBackground": true // Must be set as background as 
the Maven commands doesn't return until the Camel application stops. 
+               }
+               
+       ]
+}
+```
+
+## Launch configuration to Attach debugger and start application
+
+The idea here is to provide a Launch configuration which will do both: start 
the Camel application and attach the Camel debugger.
+
+In `.settings/launch.json` (the file might need to be created), you need to 
add this kind of configuration:
+
+```json
+{
+       "version": "0.2.0",
+       "configurations": [
+               {
+                       "name": "Run with Camel Debugger",
+                       "type": "apache.camel",
+                       "request": "attach",
+                       "preLaunchTask": "Run Camel application with debug 
Profile" // This must match the label provided as task
+               }
+       ]
+}
+```
+
+On slow connection, it might not work the first time as the timeout to connect 
the debugger will be hit. It is not yet configurable, just relaunch it.
+
+## Run & Debug
+
+Last action is to call the Launch configuration. If you have a single launch 
configuration, hitting `F5` shoudl work. Otherwise, you can go to the `Run and 
Debug panel` and then `Run & Debug` the launch configuration that you just 
configured.
+
+Time to set breakpoints and enjoy!
+
+# Resources
+
+[Here](https://github.com/apupier/camel-examples/tree/Demo-for-blogpost/examples/main)
 you can see a branch of the Camel Main example with metadata preconfigured for 
VS Code.
+
+I created a short video to see all of that in action here.

Review Comment:
   to update Video mentioned to be created, published and link to be provided 
in the blogpost.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to