3

I have written a scheduler in my spring integration application and it is working as expected for success scenarios. i have a question regarding error scenario's and how to handle it. This is the definition of the scheduler -

<task:scheduled-tasks>
    <task:scheduled ref="scheduler" method="process" trigger="cronSchedule" />
</task:scheduled-tasks>

<bean id="cronSchedule" class="org.springframework.scheduling.support.CronTrigger">
    <constructor-arg type="java.lang.String" value="data"/>
    <constructor-arg type="java.util.TimeZone" ref="timeZone"/>
</bean>

What I want to know is there a way to define a error channel for this scheduler like we do in spring chain?

I have a global errorChannel defined in my spring integration and I was hoping to invoke it when there is any error during the execution of this scheduler. Can someone help me with possible configuration to handle this situation?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Vaibs
  • 51
  • 5

1 Answers1

5

Consider using a cron poller with an inbound-channel-adapter instead of a scheduled task; then you can add an error-channel to the poller to handle errors (errors will go to the global error channel by default).

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Hi Gary , in this same scenario I'm running a "MessageGroupStoreReaper" in scheduled task as mentioned on documentation , is there way to catch the error on the global "errorChannel" ? Please suggest – Abdul Mohsin Nov 20 '20 at 18:40
  • In normal aggregation it works fine but in case of timeout its not going on global "errorChannel" , I believe "scheduled task" which is executing the reaper is the culprit. – Abdul Mohsin Nov 20 '20 at 18:45
  • Don't ask new questions in comments on 2 year old answers; it doesn't help others find answers. I am not sure what "error" you are talking about. Messages in expired groups can either be sent to the `discardChannel` or aggregated as a partial result. There is no "error" in this case. If this is not clear, ask a new question with much more detail. – Gary Russell Nov 20 '20 at 19:11
  • Thanks Gary , I'm taking about a scenario where "send-partial-result-on-expiry" is true but while processing we got some exception in code which is not getting forwarded to the global "errorChannel" – Abdul Mohsin Nov 23 '20 at 05:26
  • I can't "guess" what you are talking about with "we got some exception". Ask a new question showing much more detail and explanation of the problem. – Gary Russell Nov 23 '20 at 14:29
  • Thanks @Gary , I should have asked a new question for this. I have resolved this using "int:request-handler-advice-chain" to catch the exception. Again many thanks for helping the community on the spring integration issues. – Abdul Mohsin Nov 24 '20 at 15:47