Saturday, February 22, 2014

Debugging ApacheMQ/Camel


  • Change activemq.bat by removing comment for the following line:
    • SET ACTIVEMQ_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
  • start ActiveMQ through command line
  • create a Maven project with NetBeans
  • add the required dependencies to project according to the modules you want to debug (the sample is for ActiveMQ 5.9 and cxf, scripting/Groovy and stream):

    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>2.12.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-script</artifactId>
            <version>2.12.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-stream</artifactId>
            <version>2.12.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>2.7.8</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty.aggregate</groupId>
            <artifactId>jetty-all-server</artifactId>
            <version>8.1.14.v20131031</version>
        </dependency>            
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-websocket</artifactId>
            <version>8.1.14.v20131031</version>
        </dependency>
  • build the project so the dependencies are downloaded to local maven  repository
  • in NetBeans go to Dependencies and select Download Sources
  • in NetBeans go to Debug menu and choose Attach Debugger
  • chgange the port to 5005 (or whatever was specified in ACTIVEMQ_DEBUG_OPTS)
  • look for the desired package/class in Dependencies, open the class, place a breakpoint, etc

No comments :

Post a Comment