2014-12-03 44 views
1

我遇到線程停滯在服務激活程序的問題,導致文件掛在SftpGatewayChannel池中耗盡時。我認爲這與SA有無效回報有關,這是正確的,因爲它們只是遞增度量標準。春季集成線程停在服務激活器

我能夠通過向SftpGateway添加default-reply-timeout來解決此問題,但這並不理想,因爲存在重試通知,並且如果存在連接問題,我不希望線程超時。我想要一個解決方案,在成功上傳並調用「Success」Service Activator後將線程返回到池。

<task:executor id="Tasker" rejection-policy="CALLER_RUNS" pool-size="${MaxThreads}" /> 

<int:channel id="SftpGatewayChannel"> 
    <int:dispatcher task-executor="Tasker" /> 
</int:channel> 

<int:service-activator id="SegmentStart" input-channel="SftpGatewayChannel" ref="SftpGateway" /> 

<int:gateway id="SftpGateway" default-request-channel="SftpOutboundChannel" error-channel="ErrorChannel" /> 

<int:channel id="SftpOutboundChannel" datatype="java.lang.String,java.io.File,byte[]" /> 

<int-sftp:outbound-channel-adapter id="SftpOutboundAdapter" 
    session-factory="SftpCachingSessionFactory" channel="SftpOutboundChannel" charset="UTF-8" > 
    <int-sftp:request-handler-advice-chain> 
     <ref bean="exponentialRetryAdvice" /> 
     <bean id="SuccessAdvice" class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice" > 
      <property name="successChannel" ref="SuccessChannel"/> 
      <property name="onSuccessExpression" value="true"/> 
     </bean> 
    </int-sftp:request-handler-advice-chain> 
</int-sftp:outbound-channel-adapter> 

<int:channel id="ErrorChannel"> 
    <int:interceptors> 
     <int:wire-tap channel="FailureChannel" /> 
    </int:interceptors> 
</int:channel> 

<int:channel id="AttemptChannel" /> 
<int:channel id="SuccessChannel" /> 
<int:channel id="FailureChannel" /> 

<int:service-activator id="AttemptMetrics" input-channel="AttemptChannel" 
    expression="T(MetricsCounter).addAttempt()" /> 
<int:service-activator id="SuccessMetrics" input-channel="SuccessChannel" 
    expression="T(MetricsCounter).addSuccesses(inputMessage.Headers.messages.size())" /> 
<int:service-activator id="FailureMetrics" input-channel="FailureChannel" 
    expression="T(MetricsCounter).addFailures(payload.getFailedMessage().Headers.messages.size())" /> 

回答

0

是的,網關希望默認回覆。您可以使用service-interface方法,而使用返回void process(Message<?> m),而不使用默認RequestReplyExchanger

或者,正如您所做的那樣,只需在網關上添加default-reply-timeout="0",該線程將立即返回,而不必等待答覆(永遠不會到來)。

...但是這是不理想......

回覆超時時鐘只有開始時的線程返回到網關,所以它不會對下游流量沒有任何影響。