【发布时间】:2018-09-14 01:30:59
【问题描述】:
我们有以下简单的基于 int-jpa 的工作流程:
[入站通道适配器] -> [服务激活器]
配置是这样的:
<int:channel id="inChannel"> <int:queue/> </int:channel>
<int:channel id="outChannel"> <int:queue/> </int:channel>
<int-jpa:inbound-channel-adapter id="inChannelAdapter" channel="inChannel"
jpa-query="SOME_COMPLEX_POLLING_QUERY"
max-results="2">
<int:poller max-messages-per-poll="2" fixed-rate="20" >
<int:advice-chain synchronization-factory="txSyncFactory" >
<tx:advice transaction-manager="transactionManager" >
<tx:attributes>
<tx:method name="*" timeout="30000" />
</tx:attributes>
</tx:advice>
<int:ref bean="pollerAdvice"/>
</int:advice-chain>
</int-jpa:inbound-channel-adapter>
<int:service-activator input-channel="inChannel" ref="myActivator"
method="pollEntry" output-channel="outChannel" />
<bean id="myActivator" class="com.company.myActivator" />
<bean id="pollerAdvice" class="com.company.myPollerAdvice" />
处理的入口点是一个不断增长的表,SOME_COMPLEX_POLLING_QUERY 是针对该表运行的。目前的流程是:
-
[Thread-1]
SOME_COMPLEX_POLLING_QUERY将只返回将busy设置为false的条目(一旦使用txSyncFactory完成轮询,我们将busy设置为true) -
[Thread-2] 这些条目将通过
myActivator,可能需要 1 分钟到 30 分钟。 -
[Thread-2] 处理完成后,我们将
busy从true设置回false
问题:即使表中所有条目的处理完成,我们也需要触发通知。
尝试的方法:我们使用pollerAdvice 的afterReturning 来确定@987654335@ 是否返回任何结果。但是,此方法将在 Thread-2 处理完所有条目之前开始返回“No Entries”。
注意:
- 相同的条目将在 24 小时后再次处理。但这次会有更多的条目。
- 我们没有使用
outbound-channel-adapter,因为我们对它没有任何要求。但是,如果这是所提议的解决方案的一部分,我们愿意使用它。
【问题讨论】:
标签: spring spring-data-jpa spring-integration