2016-04-12 31 views
2

任何人使用Spring收件人列表路由器具有超时属性?春季集成 - 收件人列表路由器超时

<int:recipient-list-router id="customRouter" input-channel="routingChannel" 
     timeout="1234" 
     ignore-send-failures="true" 
     apply-sequence="true"> 
    <int:recipient channel="channel1"/> 
    <int:recipient channel="channel2"/> 
</int:recipient-list-router> 

超时: 的超时属性指定在毫秒的最大时间量等,将消息发送到目标消息通道时。默认情况下,发送操作将无限期阻止。

我正在尝试计算在移到下一个频道之前等待的时间。

+0

什么是您的输出频道?如果它不是一个队列(有限大小),那么你不需要放任何超时。 –

+0

它是一个队列频道,我想知道等待的时间有多长? –

回答

2

眼下这听起来像:

<xsd:attribute name="timeout" type="xsd:string"> 
     <xsd:annotation> 
      <xsd:documentation> 
       Specify the maximum amount of time in milliseconds to wait 
       when sending Messages to the target MessageChannels if blocking 
       is possible (e.g. a bounded queue channel that is currently full). 
       By default the send will block indefinitely. 
       DEPRECATED in favor of 'send-timeout' for consistency with other elements. 
      </xsd:documentation> 
     </xsd:annotation> 
    </xsd:attribute> 

,请注意bounded queue channel短语。因此,只有当您的目标渠道受到QueueChannel的限制时,才会通过MessagingTemplate应用此功能。

所以,如果你的频道是DirectChannel,那么等待没有任何可能。仅仅因为AbstractMessageRouter是一个简单的loop逻辑,而send因此处理过程是在同一个线程上执行的。

+0

它是一个队列通道,我想知道等待的时间有多长? –

+2

是的......在提出TimeoutException之前,需要等待一段时间。考虑与HTTP客户端或任何TCP/IP交互相同的场景。我会说,看看发件人是更好的方法:他是如何等待你的。所以,这实际上取决于目标应用程序,并且该选项不适合某些常规配方,因为您希望从我们那里听到。 –

+1

@PrasadParavatha:等待很长的时间将是你不会阻止它太久的地方,并且你不会过早地丢弃包:)) –