2015-02-10 109 views
-1

我有一个在Tomcat服务器上执行CRUD操作的Spring MVC Web应用程序。我可以在Tomcat之前使用Mule ESB作为请求处理程序吗?例如,用户请求localhost:8181/user/create(Mule ESB端口)和Mule重定向请求到localhost:8080/user/create(Tomcat服务器端口),并通过mule发回响应。我使用Mule ESB进行web服务,但我不明白我如何使用Mule ESB来处理Web应用程序请求。Mule ESB + TOMCAT Web应用程序集成

回答

1

您可以使用3.6发布了新的HTTP模块,并使用该流创建一个代理:

<?xml version="1.0" encoding="UTF-8"?> 
<mule xmlns="http://www.mulesoft.org/schema/mule/core" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:http="http://www.mulesoft.org/schema/mule/http" 
     xsi:schemaLocation=" 
       http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
       http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd"> 

    <http:listener-config name="proxyConfig" host="localhost" port="${proxyPort}" /> 
    <http:request-config name="requestConfig" host="localhost" port="${httpPort}" /> 
    <flow name="proxyTemplate"> 
     <http:listener config-ref="proxyConfig" path="/*" responseStreamingMode="AUTO" parseRequest="false" > 
      <http:response-builder statusCode="#[message.inboundProperties['http.status']]" reasonPhrase="#[message.inboundProperties['http.reason']]" /> 
     </http:listener> 

     <copy-properties propertyName="*" /> 
     <remove-property propertyName="http.*" /> 
     <copy-attachments attachmentName="*" /> 

     <set-property propertyName="X-Forwarded-For" value="#[message.inboundProperties['http.remote.address']]" /> 

     <http:request config-ref="requestConfig" method="#[message.inboundProperties['http.method']]" path="#[message.inboundProperties['http.request.path']]" parseResponse="false" > 
      <http:request-builder> 
       <http:query-params expression="#[message.inboundProperties['http.query.params']]" /> 
      </http:request-builder> 
     </http:request> 

     <copy-properties propertyName="*" /> 
     <remove-property propertyName="http.*" /> 
     <copy-attachments attachmentName="*" /> 
    </flow> 

</mule>