title: Handling Errors in Spring integration Poller
body: <p>I'm using <code>FtpStreamingMessageSource</code> in combination with poller with following config (<code>@InboundChannelAdapter(channel = "ftpChannel", poller = @Poller("pollerMetadata"))</code>):</p>
  
  <pre><code>@Bean
      public PollerMetadata pollerMetadata(PlatformTransactionManager transactionManager) {
          PeriodicTrigger trigger = new PeriodicTrigger(TimeUnit.SECONDS.toMillis(30));
          trigger.setFixedRate(true);
  
          MatchAlwaysTransactionAttributeSource source = new MatchAlwaysTransactionAttributeSource();
          source.setTransactionAttribute(new DefaultTransactionAttribute());
          TransactionInterceptor interceptor = new TransactionInterceptor(transactionManager, source);
  
          PollerMetadata metadata = new PollerMetadata();
          metadata.setTrigger(trigger);
          metadata.setTransactionSynchronizationFactory(synchronizationFactory());
          metadata.setAdviceChain(Collections.singletonList(interceptor));
          return metadata;
      }
  </code></pre>
  
  <p>It was working OK, until today I had a DB problem and an exception <code>The last packet sent successfully to the server was 30,079 milliseconds ago.</code> and <code>(ERROR): LoggingHandler org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is java.sql.SQLException: Connection is
  closed</code>.</p>
  
  <p>Somehow, poller stopped working after this, even though HikariCP managed to recover from exception after a while. Seems like a thread that was doing polling job was terminated.</p>
  
  <p>Any idea how to make thread recover and continue with processing? After I restarted application, everything was back to normal.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>this is the last exception I got before poller stopped working</p>
  
  <pre><code>2019-03-06 14:34:45 (ERROR): LoggingHandler org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is java.sql.SQLException: Connection is
  closed
          at org.springframework.jdbc.datasource.DataSourceTransactionManager.doRollback(DataSourceTransactionManager.java:290)
          at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:853)
          at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:830)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:503)
          at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:285)
          at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
          at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
          at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
          at com.sun.proxy.$Proxy71.call(Unknown Source)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:353)
          at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:55)
          at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
          at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51)
          at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:344)
          at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
          at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
          at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
          at java.lang.Thread.run(Thread.java:748)
  Caused by: java.sql.SQLException: Connection is closed
          at com.zaxxer.hikari.pool.ProxyConnection$ClosedConnection.lambda$getClosedConnection$0(ProxyConnection.java:489)
          at com.sun.proxy.$Proxy67.rollback(Unknown Source)
          at com.zaxxer.hikari.pool.ProxyConnection.rollback(ProxyConnection.java:370)
          at com.zaxxer.hikari.pool.HikariProxyConnection.rollback(HikariProxyConnection.java)
          at org.springframework.jdbc.datasource.DataSourceTransactionManager.doRollback(DataSourceTransactionManager.java:287)
          ... 22 more
  </code></pre>