[英]How to send every request to another HTTP server in Mule ESB for logging
I'm new to Mule ESB. 我是Mule ESB的新手。 So I'm use a simple config for web-service-proxy. 因此,我为Web服务代理使用了一个简单的配置。 I need to send a HTTP get request to a log server every time a web-service-proxy called(for example Service1). 每次调用Web服务代理(例如Service1)时,我都需要向日志服务器发送HTTP get请求。 How can I do that? 我怎样才能做到这一点?
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns:https="http://www.mulesoft.org/schema/mule/https"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:pattern="http://www.mulesoft.org/schema/mule/pattern"
xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
xmlns:ss="http://www.springframework.org/schema/security"
xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/current/mule-pattern.xsd http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd http://www.mulesoft.org/schema/mule/https
http://www.mulesoft.org/schema/mule/https http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd
http://www.mulesoft.org/schema/mule/https/current/mule-https.xsd http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd
http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd
http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd http://www.mulesoft.org/schema/mule/pattern
http://www.mulesoft.org/schema/mule/pattern http://www.mulesoft.org/schema/mule/pattern/3.3/mule-pattern.xsd
http://www.mulesoft.org/schema/mule/pattern/3.3/mule-pattern.xsd http://www.mulesoft.org/schema/mule/spring-security
http://www.mulesoft.org/schema/mule/spring-security http://www.mulesoft.org/schema/mule/spring-security/3.3/mule-spring-security.xsd
http://www.mulesoft.org/schema/mule/spring-security/3.3/mule-spring-security.xsd http://www.springframework.org/schema/security
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/security/spring-security-3.1.xsd http://www.mulesoft.org/schema/mule/ee/jdbc
http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd" version="EE-3.4.0">
<http:connector name="NoSessionConnector" doc:name="HTTP\HTTPS">
<service-overrides sessionHandler="org.mule.session.NullSessionHandler" />
</http:connector>
<pattern:web-service-proxy name="Service1" >
<http:inbound-endpoint address="http://esb.local:15000/service1" />
<http:outbound-endpoint address="http://esb.test.com/service1" />
</pattern:web-service-proxy>
</mule>
Thank Misbah! 谢谢米斯巴! I'm use the second solution (routing). 我正在使用第二种解决方案(路由)。
<flow name="HelloWorld" doc:name="HelloWorld">
<!--<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8888" doc:name="Http Endpoint"/>-->
<http:inbound-endpoint address="http://esb.local:8090/test.html"/>
<http:outbound-endpoint
method="GET" exchange-pattern="request-response"
address="http://www.weather.com/test.html"
contentType="text/html" doc:name="HTTP"/>
<wire-tap>
<http:outbound-endpoint address="http://logserver/index.php" exchange-pattern="one-way"/>
</wire-tap>
</flow>
Try to use splitter pattern and point two end points. 尝试使用分离器模式并指向两个端点。
https://docs.mulesoft.com/mule-user-guide/v/3.6/splitter-flow-control-reference https://docs.mulesoft.com/mule-user-guide/v/3.6/splitter-flow-control-reference
or you can use this one it will be fit for your purpose. 或者您可以使用此工具,它会适合您的目的。
https://docs.mulesoft.com/mule-user-guide/v/3.7/routers#wiretap https://docs.mulesoft.com/mule-user-guide/v/3.7/routers#wiretap
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.