Исключение Spring Integration всегда не достигает errorChannel

<bean id = "triggerFileScanner" class = "abc.xyz">
    <property name = "triggerFile" value = "value1" />
</bean>

<int-file:inbound-channel-adapter id = "fileInbound" directory = "somepath/directory" filter = "acceptallFilter" scanner = "triggerFileScanner"
    auto-startup = "true" channel = "fileChannel">
    <int:poller max-messages-per-poll = "10" time-unit = "SECONDS" fixed-delay = "10" receive-timeout = "30000" />
</int-file:inbound-channel-adapter> 

<int:header-enricher id = "headerEnricher" input-channel = "fileChannel" output-channel = "processChannel">
    <int:header name = "flowName" value = "Name" />
    <int:header name = "flowID" method = "uuidgenerate" ref = "headerEnricherBean" />
    <int:header name = "flowStartTime" method = "generateTimeString" ref = "headerEnricherBean"></int:header>
    <int:header name = "fileName" method = "deriveFileName" ref = "headerEnricherBean" />
</int:header-enricher>

<int:channel id = "processChannel">
    <int:interceptors>
        <int:wire-tap channel = "copyChannel" id = "copyTap" />
    </int:interceptors>
</int:channel>
<int:channel id = "copyChannel"></int:channel>

<int-file:outbound-channel-adapter id = "fileCopier" channel = "copyChannel" delete-source-files = "false" filename-generator = "dateSuffixFileNameGenerator"
    directory = "copy.path">
</int-file:outbound-channel-adapter>


<int:filter id = "formatcheckFilter" ref = "formatValidator" method = "validateFile" input-channel = "processChannel" output-channel = "processDataChannel"
    discard-channel = "errorChannel" auto-startup = "true">
</int:filter>

<int:service-activator id = "converter" input-channel = "processDataChannel" method = "convert" ref = "fileToQueryConverter" auto-startup = "true"
    output-channel = "impChannel" />

<bean id = "importer" class = "testbean.import">
    <property name = "errorpath" value = "path1" />
    <property name = "sourcepath" value = "path2" />
</bean>

<int:service-activator input-channel = "impChannel" ref = "impeximporter" id = "importProcess" method = "import" auto-startup = "true"
    output-channel = "archiveChannel" />

<int:channel id = "archiveChannel">
    <int:interceptors>
        <int:wire-tap channel = "logChannel" id = "completionLogger" />
    </int:interceptors>
</int:channel>

<int:channel id = "logChannel"></int:channel>

<int-file:outbound-channel-adapter id = "fileArchiver" channel = "archiveChannel" delete-source-files = "true" filename-generator = "dateSuffixFileNameGenerator"
    directory = "archive.path">
</int-file:outbound-channel-adapter>

<int:service-activator id = "flowLogger" input-channel = "logChannel" ref = "messageLogger" method = "logMessage">
</int:service-activator>

Иногда исключения из активатора службы отправляются в канал ошибок, но иногда не отправляются.

У меня есть канал ошибки, определенный ниже:

<int:channel id = "errorChannel" />

<bean id = "exceptionHandler" class=my.custom.ExceptionHandler">
</bean>
<int:service-activator id = "errorLogger" input-channel = "errorChannel" method = "handle" ref = "exceptionHandler">
</int:service-activator>

У меня этот канал ошибки используется во многих интеграциях, и в моих активаторах служб я просто выполняю исключение throw («Сообщение»)

Я даже попытался добавить канал ошибки во входящий адаптер, но все еще сталкивался с той же проблемой

Chaitanya Reddy 07.12.2018 15:02

Начните с включения ведения журнала DEBUG и следите за сообщениями в потоке.

Gary Russell 07.12.2018 15:37
смелый Ниже то, что я вижу в журналах в конце, я вижу, что сообщение достигло errorchannel, но мой активатор службы канала не называется DEBUG [task-scheduler-7] [DirectChannel] postSend (sent = true) on channel 'errorChannel' , сообщение: ErrorMessage [payload = org.springframework.messaging.MessageHandlingExcept‌ ion: вложенное исключение - java.lang.Exception: Impex Import не удалось, заголовки = {history = errorChannel, id = e5be52d1-4b2b-6c53-d02d-452db0da35af, timest0da35af = 1544194435320}]
Chaitanya Reddy 07.12.2018 16:11

Кроме того, чуть выше исключения я также вижу этот обработчик [ServiceActivatingHandler] 'ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessa‌ geProcessor @ 5811c85d‌]' не дал ответа на запрос Сообщение: ErrorMessage [payload = org.spragingframework .MessageHandlingExcept‌ ion: вложенное исключение - java.lang.Exception: Ошибка импорта, заголовки = {history = errorChannel, id = e5be52d1-4b2b-6c53-d02d-452db0da35af, timestamp = 1544194435320}]

Chaitanya Reddy 07.12.2018 16:14

Исключение дошло до errorChannel только из активных компонентов вроде этого <int-file:inbound-channel-adapter>. Если вы отправляете сообщения активатору службы вручную, вызывающему абоненту выдается исключение. Он не подходит к errorChannel только потому, что является исключением.

Artem Bilan 07.12.2018 16:44

@ArtemBilan, можете ли вы сказать, что мне делать, следует ли обрабатывать эти исключения в самом активаторе службы? Кроме того, иногда я вижу, что они достигают ServiceActivator для [org.springframework.integration.handler.MethodInvokingMessa‌ geProcessor @ 687721e0‌] (errorLogger) получено сообщение: ErrorMessage [payload = org.springframework.messaging.MessageHandlingExcept‌except .lang.Exception: Ошибка импорта, заголовки = {history = errorChannel, id = 39dee136-fb77-3109-c685-cd4957058861, timestamp = 1544198126295}]

Chaitanya Reddy 07.12.2018 16:53

Нам нужно увидеть весь поток (docs.spring.io/spring-integration/docs/current/reference/ht ml /…), из-за которого ошибка не отправляется на errorChannel. Как я уже сказал: ваш адаптер канала опроса источника отправляет исключения на errorChannel, а прямые вызовы - нет. Вы можете использовать ExpressionEvaluatingRequestHandlerAdvice в таких случаях: docs.spring.io/spring-integration/docs/current/reference/htm‌ l /…

Artem Bilan 07.12.2018 17:02

И не помещайте логи в комментарии - это сложно читать - вместо этого отредактируйте вопрос.

Gary Russell 07.12.2018 17:18
0
8
124
0

Другие вопросы по теме