【问题标题】:timeout issues in spring integration gateway for soap request and reply用于soap请求和回复的spring集成网关中的超时问题
【发布时间】:2014-10-26 07:14:49
【问题描述】:

在从我的界面(使用 spring 集成)设置到 ESB 接口的肥皂请求超时时,我面临一些挑战。在将请求发送到 ESB 接口时,我设置了请求超时 = 5000 毫秒和回复超时 = 5000 毫秒,但如果 ESB 接口上的服务关闭,则请求在所需的 5000 毫秒(5 秒)超时时间和超时时间内不会超时有时在 40 秒或更长时间内。我尝试将默认请求超时和默认回复超时选项也与 int:gateway 配置一起使用,但同样的问题。请看下面的配置完成:

<int:gateway id="SoapESBGateway"
            service-interface="test.soap.service.ServiceSoap">
            <int:method name="ServiceResponse"
                request-channel="RequestChannel" reply-channel="ReplyChannel"
                request-timeout="5000" reply-timeout="5000" />
        </int:gateway>

        <int:chain input-channel="RequestChannel" output-channel="ReplyChannel">
        <int-xml:marshalling-transformer marshaller="marshaller" result-transformer="resultTransformer"></int-xml:marshalling-transformer>

        <int:transformer ref="TransformerBean" method="transformMethod"></int:transformer>

        <int-ws:outbound-gateway id="ws-SoapESB-gateway" ignore-empty-responses="true" uri="${soap.URI}"></int-ws:outbound-gateway>

        <int:transformer ref="TransformerBean" method="transformMethod"></int:transformer>

        <int-xml:unmarshalling-transformer unmarshaller="marshaller"></int-xml:unmarshalling-transformer>
        </int:chain>


        <bean id="resultTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
        <bean id="TransformerBean" class="test.TransformerImpl"></bean>

如果我在设置超时选项时遗漏了什么,请告诉我。

谢谢, 维奈A


更新:

<int:gateway id="SoapESBGateway"
                service-interface="test.soap.service.ServiceSoap">
                <int:method name="ServiceResponse"
                    request-channel="RequestChannel" reply-timeout="5000" />
            </int:gateway>

            <int:chain input-channel="RequestChannel">
            <int-xml:marshalling-transformer marshaller="marshaller" result-transformer="resultTransformer"></int-xml:marshalling-transformer>

            <int:transformer ref="TransformerBean" method="transformMethod"></int:transformer>

            <int-ws:outbound-gateway id="ws-SoapESB-gateway" ignore-empty-responses="true" uri="${soap.URI}" message-sender="messageSender"></int-ws:outbound-gateway>

            <int:transformer ref="TransformerBean" method="transformMethod"></int:transformer>

            <int-xml:unmarshalling-transformer unmarshaller="marshaller"></int-xml:unmarshalling-transformer>
            </int:chain>


            <bean id="resultTransformer" class="org.springframework.integration.xml.transformer.ResultToStringTransformer" />
            <bean id="TransformerBean" class="test.TransformerImpl"></bean>

<bean id ="messageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender">
    <property name="connectionTimeout" value="2000"></property>
    </bean>

如上所述,我添加了带有 int-ws:outbound-gateway 的 messageSender bean 引用,并设置了属性 connectiontimeout = 2sec,但我仍然可以看到,当网络关闭时,它正在等待 19 秒的第一次命中和下一次命中,少于 19 秒,但至少不是第一次命中所需的超时。那么我们是否没有任何选择可以确定所需的超时始终有效。

谢谢, 维奈

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    首先,请阅读本章:http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/messaging-endpoints-chapter.html#d4e4197

    根据您的配置,您有direct 流,因此没有理由拥有request-timeoutreply-channel

    您的40sec 的问题在该WS 网关的WebServiceMessageSender 下。在您的情况下,默认情况下为 HttpUrlConnectionMessageSender。在HttpURLConnection 中有一些connectTimeout 属性。

    我不确定如何更改它,但我更喜欢使用 HttpComponentsMessageSender 来更好地控制 HTTP 连接。

    现在问题Why is it 40sec, but not those 5sec from reply-timeout?。因为您的线程在send 上被阻塞,并且尚未到达wait reply 部分。

    【讨论】:

    • 嗨 Artem,当按照建议合并更改时,我仍然面临超时问题。我已经用我仍然面临的问题更新了我的查询区域。需要你的建议。
    • 我建议您进行调试以确定您的程序的哪个部分需要那个时间。顺便说一句,Sender - readTimeout 还有另一个选项。
    猜你喜欢
    • 1970-01-01
    • 2013-07-08
    • 2012-03-19
    • 1970-01-01
    • 2013-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多