Saturday, April 7, 2012

Activating Zend Debugger via Mule


Mule can provide translation services between applications while acting as a common Enterprise Service Bus.   It’s very useful, but it’s also aptly named.  It’s stubborn, and it has the worst documentation, bar none, of any tool I have ever used.  

But all griping aside, the fact is, it’s sitting between two applications I need to communicate with each other.  And I want to debug the receiving application.  So how can I cause the receiving application to trigger Zend Debugger when it receives the data from Mule?  

The original mule configuration looks like this:

<http:outbound-endpoint
   host="receiving-application"
   port="80"
   path="index.php/catalog/updatePrice"
   contentType="text/xml"
   mimeType="text/plain"
   exchange-pattern="one-way"
/> 


We simply add the cookies into the header using a <properties> statement.  Note that a lot of the time, you will see endpoints defined as <http:outbound-endpoint host port etc/> with no closing tag because the "/" at the end of the tag closed it already.  In that case, just remove the trailing "/" and put a </http:outbound-endpoint> tag at the end as I have done here.

<http:outbound-endpoint
   host="receiving-application"
   port="80"
   path="index.php/catalog/updatePrice"
   contentType="text/xml"
   mimeType="text/plain"
   exchange-pattern="one-way"
> 
   <properties>
      <spring:entry key="cookies">
         <spring:map>
            <spring:entry key="start_debug" value="1" />
            <spring:entry key="debug_fastfile" value="1" />
            <spring:entry key="debug_host" value="127.0.0.1" />
            <spring:entry key="use_remote" value="1" />
            <spring:entry key="debug_port" value="10137" />
            <spring:entry key="original_url" value="http://receiving_application" />
            <spring:entry key="debug_stop" value="1" />
            <spring:entry key="debug_session_id" value="1005" />             
         </spring:map>
      </spring:entry>
   </properties
</http:outbound-endpoint>


Don’t forget to include the spring definitions at the top of the file:
xmlns:spring="http://www.springframework.org/schema/beans"

and:
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  
If you need help setting up remote debugging in general, see my blog here: http://www.klugedeforce.com/2012/02/remote-debugging-cli-over-ssh-tunnel-in.html

I particularly like this method because it doesn’t require modification of the outgoing data in the sending application.  I have had problems with Mule stripping out the cookie information.  I am sure there is a way to convince Mule not to strip the cookies, but I haven't invested any serious effort in figuring it out because this method is generally easier.  And even if you were say polling an FTP server for a file and then posting the results as PHP, you can still intercept the incoming transaction this way.  So it's more universally applicable as well.

No comments:

Post a Comment