【问题标题】:Spring integration-Service activator getting called twiceSpring integration-Service activator 被调用两次
【发布时间】:2014-03-04 14:59:23
【问题描述】:

嗨,这是我的 spring 集成配置。当我使用 mozilla fire fox rest 控制台访问我的服务两次时,它会被调用。例如,如果我在 service-activator(CA 请求激活器)中访问了某些服务,则确定不可预测它被调用两次的场景。我不知道是 mozilla 问题还是配置问题。我尝试使用新窗口,但这个问题仍然存在。在第一种情况下,我的服务激活器正确返回 xml 响应,但立即再次被调用。仅在罕见情况下假设它调用了两次。

    <int:channel id="accountRequest" />
    <int:channel id="accountResponse" />
    <int:channel id="catRequestChannel" />
    <int:channel id="mataccountRequest" />
    <int:channel id="errorChannel"/>



    <int-http:inbound-gateway id="cwebAccountManagementGateway"     
        supported-methods="GET, POST" 
        request-channel="accountRequest"
        reply-channel="accountResponse" 
        mapped-request-headers="*"      
        mapped-response-headers="*" 
        view-name="/policies" 

        path="/services/{class}/{method}"
        reply-timeout="50000"
error-channel="errorChannel">




        <int-http:header name="serviceClass" expression="#pathVariables.class"/>
        <int-http:header name="serviceMethod" expression="#pathVariables.method"/>

    </int-http:inbound-gateway>


    <int:header-value-router input-channel="accountRequest"
        header-name="state"
        default-output-channel="accountRequest" resolution-required="false">
        <int:mapping value="MA"
            channel="mataccountRequest" />
            <int:mapping value="CA"
            channel="catRequestChannel" />

    </int:header-value-router>

    <int:service-activator id="accountServiceActivator" 
                input-channel="mataccountRequest"
                output-channel="accountResponse" 
                ref="serviceGatewayAdapter" 
                method="requestHandler" 
                send-timeout="60000"/>

        <int:service-activator id="caRequestActivator" 
                input-channel="catRequestChannel"
                output-channel="accountResponse" 
                ref="caServiceGatewayAdapter" 
                method="requestHandler" 
                send-timeout="60000"/>

                 <int:service-activator id="errorRequestActivator" 
                input-channel="errorChannel"
                output-channel="accountResponse" 
                ref="errorGatewayAdapter" 
                method="errorHandler" 
                send-timeout="60000"/>

例如:这是我的网址

http://localhost:9085/springintegrationsample/create?mail=15999999@mail.com&idNumber=80010600010            

如果我将邮件编辑为其他值,它将被调用两次 如果我改变 agan 它工作正常。我不明白在什么情况下它会被调用两次

【问题讨论】:

  • 我建议您打开 DEBUG 日志记录并通过流程跟踪消息。还要查看您的应用服务器访问日志,看看浏览器是否发送了两个请求。

标签: spring-integration


【解决方案1】:

您对两个服务激活器使用相同的“requestHandler”,因此很明显它会被调用两次。 您无法知道为处理程序方法调用了哪个激活器,因为在调试时您只能检查正在调用的处理程序方法。 为了更好地处理这个问题,请为每个服务激活器使用不同的处理程序方法。即使他们使用类似的操作,它也会更加清晰和易于调试。

我建议添加通道拦截器来记录传入和传出消息,以便更好地了解。

干杯

【讨论】:

    猜你喜欢
    • 2019-06-29
    • 2017-09-16
    • 2019-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-15
    • 1970-01-01
    相关资源
    最近更新 更多