Exit Spring Integration when no more messages -
i'm using spring integration (4.1) config retrieve message db batch more service. know i'll have dozen of messages process daily, , therefore need run batch once day.
my jdbc:inbound-channel-adapter configured retrieve max-rows-per-poll="1". i'd notified in way when there no more messages, can exit batch, have issues finding "plug". tried interceptor remembers when last message went through + scheduled task retrieves timestamp , checks if it's more configured timeout, felt cumbersome , tried aop instead, feels better solution.
i'd intercept call abstractpollingendpoint.dopoll() returns false when there's no message i'm not able find way : tried subclassing abstractrequesthandleradvice doesn't work when applied on poller (it tells me in logs). i'm trying implement methodinterceptor , configure below, , see can intercept call "call" method, i'm not sure it's right way
<int:poller default="true" trigger="periodictriggerwithinitialdelay"> <int:advice-chain> <bean class="com.mybatch.nomoremessagenotifieradvice" /> <ref bean="txadvice"/> </int:advice-chain> </int:poller>
isn't there easier way ? main difficulty, stated here http://forum.spring.io/forum/spring-projects/integration/127410-poller-with-advice-chain , @ stage, don't have message work on.
thanks
vincent
looks close answer actually.. since have access result of call method, need throw exception if result false, along xml config question :
public class nomoremessagenotifieradvice implements methodinterceptor {
@override public object invoke(methodinvocation invocation) throws throwable { object result=invocation.proceed(); if(result instanceof boolean){ boolean haspolledamessage=(boolean)result; if(haspolledamessage){ return true; } else{ throw new stopbatchexception("no message received on latest poll -> throwing exception exit"); } } return result; }
}
Comments
Post a Comment