gpt4 book ai didi

java - Mule ESB + TOMCAT Web 应用集成

转载 作者:行者123 更新时间:2023-11-28 23:57:42 26 4
gpt4 key购买 nike

我有一个在 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 应用程序请求。

最佳答案

您可以使用 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>

关于java - Mule ESB + TOMCAT Web 应用集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28428343/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com