简体   繁体   中英

How to send every request to another HTTP server in Mule ESB for logging

I'm new to Mule ESB. So I'm use a simple config for web-service-proxy. I need to send a HTTP get request to a log server every time a web-service-proxy called(for example Service1). 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM