0

フローで 2 つの HTTP エンドポイントを使用すると、Mule がこの例外をスローします。この問題に対処する方法を見つけました。非同期モードで 2 番目の HTTP エンドポイントを使用しますが、これは良い方法ではありません。

ERROR DefaultSystemExceptionStrategy [[testdemo].connector.http.mule.default.receiver.03]: Caught exception in Exception Strategy: Attempted read on closed stream.
java.io.IOException: Attempted read on closed stream.
    at org.apache.commons.httpclient.AutoCloseInputStream.isReadAllowed(AutoCloseInputStream.java:183)
    at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:126)
    at org.mule.model.streaming.DelegatingInputStream.read(DelegatingInputStream.java:58)
    at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1025)
    at org.mule.transformer.simple.ObjectToOutputHandler$3.write(ObjectToOutputHandler.java:76)
    at org.mule.transport.http.HttpServerConnection.writeResponse(HttpServerConnection.java:315)
    at org.mule.transport.http.HttpMessageReceiver$HttpWorker.run(HttpMessageReceiver.java:164)
    at org.mule.work.WorkerContext.run(WorkerContext.java:311)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

私のコード:

<flow doc:name="httpPost" name="httpPost">
    <http:inbound-endpoint doc:name="HTTP" keep-alive="true"
        exchange-pattern="request-response" host="localhost" path="service"
        port="8082" />

    <http:body-to-parameter-map-transformer />

    <!-- This component is just set to show the message accecpted from the request -->
    <scripting:component>
        <scripting:script engine="groovy">
            println payload['name']
            return payload['name']+'123'
        </scripting:script>
    </scripting:component>
</flow>

<flow doc:name="httpPost" name="client">
    <http:inbound-endpoint doc:name="HTTP" name="httpClient"
        exchange-pattern="request-response" host="localhost" path="client"
        port="8082" encoding="UTF-8" />

    <http:body-to-parameter-map-transformer />

    <scripting:component>
        <scripting:script engine="groovy">
            payload['name'] = 'opasso'
            def paramstr = ""
                for( param in payload){
                paramstr = paramstr + "&amp;" + param.key+ "=" + param.value
            }
            println "querystr:$paramstr"
            return paramstr.substring(1)
        </scripting:script>
    </scripting:component>

    <http:outbound-endpoint address="http://localhost:8082/service"
        exchange-pattern="request-response" contentType="application/x-www-form-urlencoded"
        method="POST" encoding="UTF-8" />

    <!-- This component is just set to show the message accecpted from the request -->
    <scripting:component>
        <scripting:script engine="groovy">
            def msg = "return payload:$payload;".toString()
            println msg
            return payload
        </scripting:script>
    </scripting:component>
</flow>
4

1 に答える 1