ssm75
ssm75

Reputation: 1

How to remote debug a Spring Cloud Data flow Task

We are using Spring XD for executing some batch jobs and considering to use Spring Cloud Dataflow. For this I wanted to remote debug a execution of a Task and I was not able to make it working.

I tried to export the following environment variable before the SCDF server is started:

spring.cloud.deployer.local.javaOpts=Xdebug -Xrunjdwp:transport=dt_socket,address=12201,server=y

Also tried to pass as argument in the GUI while invoking the task:

app.<appname>.local.javaOpts=Xdebug -Xrunjdwp:transport=dt_socket,address=12201,server=y

Nothing seems to be working.

Upvotes: 0

Views: 1224

Answers (3)

ssm75
ssm75

Reputation: 1

Finally I was able to remote debug a composed task or regular task. Follow the below steps:

  1. In scdf UI go to tasks and click on the definition section
  2. Click play button (invoke) on the task/composed task that you want to invoke.
  3. On the launch task page define your task arguments
  4. Add the following properties by clicking 'Add Property' button: - deployer.composed-task-runner.local.debugPort=12103 - deployer.composed-task-runner.local.debugSuspend=y
  5. Now launch the task

You can now see in the log that when the composed task's java process is launched it is called with the debug parameter.

If you want to control the heap memory or any java options you can do by adding the following property: deployer.composed-task-runner.local.javaOpts=Xmx2048M Note that 'composed-task-runner' is the name of the App (Not the name of the task).

Upvotes: 0

Alexander.Furer
Alexander.Furer

Reputation: 1869

I'm able to debug the composed-task-runner launched by SCDF using the listen debugger mode, this will also work for your task as well.

  1. Run Debugger in your IDE in listen mode on port 5006. (this project's classpath should have composed-task-runner sources, put break point some where )
  2. Run SCDF with -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 option, attach debugger to the SCDF process in your IDE on port 5005 (attach mode).
  3. Put breakpoint at this line : String javaOptsString = getValue(deploymentProperties, "javaOpts"); in JavaCommandBuilder class (for spring-cloud-deployer-local v.1.3.0.M2 it's line #83).
  4. Launch your task - debugger stops at breakpoint.
  5. Step Over once in your IDE, the value of javaOptsString is null now. Using IDE, set the value of javaOptsString to

    -agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5006,suspend=y

  6. Press Resume in IDE.

  7. Your breakpoint set in #1 should be hit in few seconds.

If you know how to pass javaOpts as deployment properties of your task - you will be able to debug in listen mode without this nightmare ;-). I've not found a way to escape = and , characters in the -agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5006,suspend=y javaOpts deployment property.

Upvotes: 1

Sabby Anandan
Sabby Anandan

Reputation: 5651

We are working on an improved solution for the local-deployer - you can follow spring-cloud/spring-cloud-dataflow#369 for tracking purpose.

There is, however, the following option that exists to aggregate all the application logs into the server console directly, which might be useful while in active development.

stream deploy --name myStream --properties "deployer.*.local.inheritLogging=true"

Upvotes: 0

Related Questions