Файл опроса Spring-integration-ftp, даже когда мое приложение остановлено

В продолжение вопроса -

Тот же файл снова и снова загружается в spring-ftp, но с разными именами

У меня есть следующая конфигурация в моем application.xml

 <?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:int="http://www.springframework.org/schema/integration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
    xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration
        http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/integration/file
        http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
        http://www.springframework.org/schema/integration/stream
        http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
        http://www.springframework.org/schema/integration/ftp
        http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd">

    <int:poller id="poller" task-executor="synchTaskExecutor" default="true" fixed-delay="1000" />

    <beans:bean id="ftpClientFactory"
          class="com.everge.springframework.integration.ftp.session.EvergeFtpSessionFactory">
        <beans:property name="host" value="111.93.128.170"/>
        <beans:property name="port" value="21"/>
        <beans:property name="username" value="singha"/>
        <beans:property name="password" value="singha16"/>
        <beans:property name="clientMode" value="2"></beans:property>
    </beans:bean>

    <beans:bean id="ftpOutClientFactory"
          class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
        <beans:property name="host" value="111.93.128.170"/>
        <beans:property name="port" value="21"/>
        <beans:property name="username" value="singha"/>
        <beans:property name="password" value="singha16"/>
        <beans:property name="clientMode" value="2"></beans:property>
    </beans:bean>

    <beans:bean id="synchTaskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
        <beans:property name="corePoolSize" value="1"></beans:property>
        <beans:property name="maxPoolSize" value="1"></beans:property>
        <beans:property name="queueCapacity" value="1"></beans:property>
    </beans:bean>

    <beans:bean id="pqqFtpClientFactory"
          class="com.everge.springframework.integration.ftp.session.PqqEvergeFtpSessionFactory">
        <beans:property name="host" value="111.93.128.170"/>
        <beans:property name="port" value="21"/>
        <beans:property name="username" value="singha"/>
        <beans:property name="password" value="singha16"/>
        <beans:property name="clientMode" value="2"></beans:property>
    </beans:bean>

    <int:channel id="ftpChannel">
        <int:queue/>
    </int:channel>

    <beans:bean id="acceptAllFileListFilter" class="com.everge.file.processing.EvergeFileListFilter"/>

       <beans:bean id="pqqHandler" class="com.everge.pqq.PqqFileHandler">
        <beans:property name="config" ref="baseConfig"></beans:property>
    </beans:bean>

    <beans:bean id="handler" scope="prototype" class="com.everge.integration.client.FileHandler">
        <beans:property name="config" ref="baseConfig"></beans:property>
    </beans:bean>

    <beans:bean id="baseConfig" class="com.everge.config.BaseConfig" />

    <beans:bean id="ftpSplitter" class="com.everge.service.FtpSplitter" />

    <beans:bean id="fileSplitter" class="com.everge.file.processing.FileSplitter" />

    <int-ftp:outbound-channel-adapter  id="notifFtpOutBound"
                channel="pl"
                remote-directory="/ADPWG/PRCSD1"
                session-factory="ftpOutClientFactory" auto-startup="true">
        <int-ftp:request-handler-advice-chain>
            <int:retry-advice />
        </int-ftp:request-handler-advice-chain>
    </int-ftp:outbound-channel-adapter>   

   <int-ftp:outbound-channel-adapter  id="ftpOutbound"
                channel="pqqOutputFileChannel"
                remote-directory="/ADPWG/PRCSD"
                session-factory="ftpOutClientFactory" auto-startup="true">
        <int-ftp:request-handler-advice-chain>
            <int:retry-advice />
        </int-ftp:request-handler-advice-chain>
    </int-ftp:outbound-channel-adapter>

    <file:inbound-channel-adapter prevent-duplicates="false" id="filesIn1" directory="file:/Users/abhisheksingh/ddrive/everge_ws/f" auto-startup="true">
        <int:poller id="poller" task-executor="synchTaskExecutor" fixed-delay="1000"></int:poller>
    </file:inbound-channel-adapter>

    <int:service-activator input-channel="filesIn1" ref="handler" />

    <file:inbound-channel-adapter prevent-duplicates="false" id="pqqInputFileChannel" directory="file:/Users/abhisheksingh/ddrive/everge_ws/pqqReq" auto-startup="true">
        <int:poller id="poller" task-executor="synchTaskExecutor" fixed-delay="1000" />
    </file:inbound-channel-adapter>

    <int:service-activator input-channel="pqqInputFileChannel" ref="pqqHandler" />

    <file:inbound-channel-adapter  id="pqqOutputFileChannel" directory="/Users/abhisheksingh/ddrive/everge_ws/pqqResp">
        <int:poller id="poller" task-executor="synchTaskExecutor" fixed-delay="10000" />
    </file:inbound-channel-adapter>

    <int-ftp:inbound-channel-adapter id="ftpInbound"
        channel="ftpChannel"
        session-factory="ftpClientFactory"
        auto-create-local-directory="true"
        delete-remote-files="false"
        local-filter="acceptAllFileListFilter"
        local-directory="file:/Users/abhisheksingh/ddrive/everge_ws/f" auto-startup="true" >
        <int:poller id="poller"  task-executor="synchTaskExecutor" fixed-delay="1000" />
    </int-ftp:inbound-channel-adapter>


    <int-ftp:inbound-channel-adapter id="pqqFtpInbound"
        channel="ftpChannel"
        session-factory="pqqFtpClientFactory"
        auto-create-local-directory="true"
        delete-remote-files="false"
        local-filter="acceptAllFileListFilter"
        local-directory="file:/Users/abhisheksingh/ddrive/everge_ws/pqqReq" auto-startup="true" >
        <int:poller id="poller" task-executor="synchTaskExecutor" fixed-delay="1000" />
    </int-ftp:inbound-channel-adapter>

    <file:inbound-channel-adapter id="pl" directory="file:/Users/abhisheksingh/ddrive/everge_ws/notifFile" auto-startup="true">
        <int:poller id="poller" task-executor="synchTaskExecutor" fixed-delay="1000" />
    </file:inbound-channel-adapter>

</beans:beans>  

Таким образом, есть местоположение ftp, которое я опрашиваю, и опрашиваемый файл помещается в следующий каталог на моей локальной машине:

/Пользователи/abhisheksingh/ddrive/тест/ф

Теперь иногда из-за того, что я нашел ошибку и должен ее исправить, я останавливаю сервер tomcat. Я удаляю файлы со своего локального сервера, чтобы в следующий раз, когда я запускаю свой сервер, тот же файл можно было снова опросить. Но я обнаружил, что тот же файл снова опрашивается. Мой сервер остановлен! Этого не должно происходить, насколько я знаю. Вот почему я разместил свой application.xml, чтобы узнать, есть ли здесь что-то, что держит потоки зависшими. Или это spring-integration-ftp запускает поток демона, который не зависит от приложения. Пожалуйста, дайте мне разгадать эту загадку.

Я вижу следующее исключение в журналах tomcat:

Feb 17, 2017 11:49:24 PM org.apache.catalina.loader.WebappClassLoaderBase loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load UNIX Type: L8.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1777)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:88)
        at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2263)
        at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2046)
        at org.springframework.integration.ftp.session.FtpSession.list(FtpSession.java:70)
        at org.springframework.integration.ftp.session.FtpSession.list(FtpSession.java:43)
        at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:236)
        at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer$1.doInSession(AbstractInboundFileSynchronizer.java:232)
        at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:435)
        at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer.synchronizeToLocalDirectory(AbstractInboundFileSynchronizer.java:232)
        at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:193)
        at org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource.doReceive(AbstractInboundFileSynchronizingMessageSource.java:59)
        at org.springframework.integration.endpoint.AbstractMessageSource.receive(AbstractMessageSource.java:134)
        at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:224)
        at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:245)
        at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:58)
        at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:190)
        at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:186)
        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:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

На данный момент я почти уверен, что ftp-опросщик spring-integration не позволяет должным образом остановиться tomcat.

Я исследовал больше, используя jvisualvm. Я вижу, что запущены потоки планировщика задач, которые не закрываются вызовом ./shutdown.sh для остановки кота.

введите здесь описание изображения

Интересно отметить, что если я удалю адаптер pl или pqqOutputFileChannel, эти планировщики не будут созданы.

Вот структура моего ушного файла -

введите здесь описание изображения

Ниже приведен журнал, который продолжает работать в файле журнала, даже когда на tomcat было вызвано завершение работы:

**541576 DEBUG o.s.i.c.PublishSubscribeChannel — postSend (sent=true) на канале «errorChannel», сообщение: ErrorMessage [payload=org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@6d6033da[Running, pool размер = 1, активные потоки = 0, задачи в очереди = 1, выполненные задачи = 1113]] не принял задачу: org.springframework.integration.util.ErrorHandlingTaskExecutor$1@7d7cc2a4, headers={id=26e6de67-2b70-cd7d-0c64 -d21e1f8d1726, timestamp=1487870801603}] 541611 DEBUG c.e.s.i.f.s.PqqEvergeFtpSessionFactory - Connected to server [111.93.128.170:21] 541638 INFO c.e.s.i.f.s.PqqEvergeFtpSessionFactory - Inside postProcessClientAfterConnect of PqqEvergeFtpSessionFactory 541778 INFO o.s.i.ftp.session.FtpSession - File has been successfully transferred from: TEST4. PQQ 541778 DEBUG o.s.i.f.i.FtpInboundFileSynchronizer — передано 1 файл 541779 INFO c.e.f.p.EvergeFileListFilter — проверьте, был ли уже обработан файл ssed /Users/abhisheksingh/ddrive/everge_ws/pqqArchive/TEST4.PQQ 541779 INFO c.e.f.p.EvergeFileListFilter - Archive file name is 541779 INFO c.e.f.p.EvergeFileListFilter - Input file name is TEST4 541779 INFO c.e.f.p.EvergeFileListFilter - Archive file name is TEST4 541779 INFO c.e.f.p.EvergeFileListFilter - Input имя файла TEST4 541779 INFO c.e.f.p.EvergeFileListFilter — файл уже обработан TEST4 541779 ОШИБКА c.e.f.p.EvergeFileListFilter — файл PQQ уже обработан. 541779 DEBUG o.s.i.e.SourcePollingChannelAdapter — не получено сообщений во время опроса, возвращается «false» 541974 DEBUG o.s.i.e.SourcePollingChannelAdapter — не получено сообщений во время опроса, возвращается «false»

Я не понимаю, что означает следующее: Но я обнаружил, что тот же файл снова опрашивается. Мой сервер остановлен! уточните пожалуйста. Похоже, вы говорите, что что-то извлекает файл с вашего FTP-сервера, даже когда ваш код (работающий в Tomcat) остановлен. Это естественно невозможно. Откуда вы вообще знаете, что что-то загружает файл с FTP, если tomcat не запущен?


person user3276247    schedule 08.02.2017    source источник
comment
Потому что, когда я удаляю файл из папки, я вижу, что тот же файл снова копируется с использованием того же механизма, который использует spring-integration-ftp. При копировании файл называется test.txt.writing, и, наконец, он записывается.   -  person nos    schedule 08.02.2017
comment
Это, естественно, невозможно. Что я могу сказать? Я так же сбит с толку, как и вы. Просто мысль, что, если приложение запускает поток демона? Это закончится, когда приложение будет остановлено?   -  person user3276247    schedule 08.02.2017
comment
Может быть, ваше приложение не привязано к жизненному циклу кота? Это действительно что-то странное. Не видел этого раньше. Контекст приложения close() должен остановить все запущенное.   -  person user3276247    schedule 08.02.2017
comment
Мне нужно перезапустить приложение, чтобы остановить это поведение.   -  person Artem Bilan    schedule 08.02.2017
comment
@user3276247 user3276247 Возможно, вы просто думаете, что остановили tomcat, но на самом деле он все еще работает. Имейте в виду, что вы не сообщаете нам подробности того, что вы делаете, поэтому нам остается только догадываться. Ты останавливаешь кота? Если да, то как остановить tomcat? Вы трижды проверяли, что tomcat не работает после того, как вы пытались его остановить? Если вы не останавливаете и не перезапускаете кота, что вы делаете? Когда вы говорите, что перезапускаете приложение, вы имеете в виду, что перезапускаете tomcat? Существуют ли какие-либо другие компоненты, кроме сервера tomcat, которые вы используете, которые относятся к вашему приложению?   -  person user3276247    schedule 09.02.2017
comment
Я запускаю ./shutdown.sh на своем Mac. После того, как я это сделаю, localhost:8080 не отображает мне страницу.   -  person nos    schedule 09.02.2017
comment
Однако, если я выполню grep, я все равно увижу, что поток существует - Abhisheks-MacBook-Pro:bin abhisheksingh$ ps -aef |grep java 501 1301 1 0 18:41 ttys000 0:17.57 /Library/Java/JavaVirtualMachines/jdk1 .8.0_112.jdk/Contents/Home/bin/java -Djava.util.logging.config.file=/Applications/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/Applications/tomcat/endorsed -classpath /Applications/tomcat/bin/boo....   -  person user3276247    schedule 12.02.2017
comment
Я использовал jvisualvm, чтобы увидеть, что есть 10 активных потоков с именами (task-scheduler-1, 2,3... 10. Также в журналах tomcat я вижу - СЕРЬЕЗНО: веб-приложение [/integration-0.0.1-SNAPSHOT ] , похоже, запустил поток с именем [task-scheduler-1], но не смог его остановить. Это, скорее всего, приведет к утечке памяти. Это в значительной степени подводит итог тому, что опросщик ftp spring-integration запускает потоки, которые сопротивляются остановке .   -  person user3276247    schedule 12.02.2017
comment
Еще одно наблюдение. Сегодня я удалил все bean-компоненты из своего application.xml и продолжал добавлять их один за другим. ‹file:inbound-channel-adapter id=pl directory=file:/Users/abhisheksingh/ddrive/tmep/notifFile auto-startup=true› ‹int:poller id=poller task-executor=synchTaskExecutor с фиксированной задержкой=1000 /› ‹/file:inbound-channel-adapter› Я видел, что если вы удалите один из таких bean-компонентов file:inbound-channel-adapter, я перестану видеть потоки, запущенные в jvisualvm, после остановки приложения.   -  person user3276247    schedule 17.02.2017
comment
Похоже, вы запускаете этот _1_ вне области Tomcat, и когда вы _2_ его, _3_ не закрывается. Нам нужно знать, как выглядит ваше приложение.   -  person user3276247    schedule 21.02.2017
comment
Приложение представляет собой обычный файл уха. application.xml является его частью.   -  person Artem Bilan    schedule 22.02.2017
comment
Я добавил снимок моего приложения.   -  person user3276247    schedule 23.02.2017
comment
541576 DEBUG o.s.i.c.PublishSubscribeChannel — postSend (sent = true) на канале «errorChannel», сообщение: ErrorMessage [payload = org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@6d6033da [Выполняется, размер пула = 1, активных потоков = 0, задач в очереди = 0, завершенных задач = 1114]] не принял задачу: org.springframework.integration.util.ErrorHandlingTaskExecutor$1@570e117d, заголовки={id=71d77a8b-17ea-7011-3cb3-ddbf7591321f , timestamp=1487870801603}] 541575 DEBUG o.s.i.c.PublishSubscribeChannel - postSend (sent=true) на канале 'errorChannel', сообщение: ErrorMessage [payload=org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@6d6033da [Выполняется, размер пула = 1, активные потоки = 0, задачи в очереди = 1, завершенные задачи = 1113]] не принял задачу: org.springframework.integration.util.ErrorHandlingTaskExecutor$1@44210f79, headers={id=74a26d65-4b42 -da1f-cdf1-b77fea8bfdb7, timestamp=1487870801603}] 541576 ОШИБКА o.s.i.handler.LoggingHandler - org.springframework.core.task.TaskRejectedException: Executor [java.util.concurrent.ThreadPoolExecutor@6d6033da[Выполняется, размер пула = 1, активные потоки = 0, задачи в очереди = 1 , выполненные задачи = 1113]] не принял задачу: org.springframework.integration.util.ErrorHandlingTaskExecutor$1@7d7cc2a4 в org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.execute(ThreadPoolTaskExecutor.java:296) в org.springframework.integration. util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:51) в org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:344) в org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java: 54) в org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) в java.util.concurrent.Executors$Runnab leAdapter.call(Executors.java:511) в java.util.concurrent.FutureTask.run(FutureTask.java:266) в java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) в java. util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) в java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) в java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 617) на java.lang. Thread.run(Thread.java:745) Вызвано: java.util.concurrent.RejectedExecutionException: Задача org.springframework.integration.util.ErrorHandlingTaskExecutor$1@7d7cc2a4 отклонена из java.util.concurrent.ThreadPoolExecutor@6d6033da[Выполняется, размер пула = 1, активных потоков = 0, задач в очереди = 1, завершенных задач = 1113] в java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047) в java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor. java:823) в java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369) в org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor.execute(ThreadPoolTaskExecutor.java:293) ... еще 11   -  person user3276247    schedule 23.02.2017