0
<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>

Sometimes the exceptions from service activator are going to the error channel, however some times they are not going.

I have the error channel defined as below:

<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>

I have this error channel being used in many integrations and in my service activators i am just doing a throw Exception("Message")

  • I even tried to add the error channel on the inbound adapter but still facing the same issue – Chaitanya Reddy Dec 07 '18 at 14:02
  • Start by turning on DEBUG logging and follow the messages through the flow. – Gary Russell Dec 07 '18 at 14:37
  • **bold** Below is what i see in the logs in the end, i see the message reached the errorchannel but my channel service activator is not called DEBUG [task-scheduler-7] [DirectChannel] postSend (sent=true) on channel 'errorChannel', message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.Exception: Impex Import failed, headers={history=errorChannel, id=e5be52d1-4b2b-6c53-d02d-452db0da35af, timestamp=1544194435320}] – Chaitanya Reddy Dec 07 '18 at 15:11
  • Also, just above the exception i also see this [ServiceActivatingHandler] handler 'ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@5811c85d]' produced no reply for request Message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.Exception: Import failed, headers={history=errorChannel, id=e5be52d1-4b2b-6c53-d02d-452db0da35af, timestamp=1544194435320}] – Chaitanya Reddy Dec 07 '18 at 15:14
  • The exception reached an `errorChannel` only from the active components like that ``. If you send messages manually to the service activator, the exception is thrown to your caller. It doesn't go to the `errorChannel` just because it is an exception. – Artem Bilan Dec 07 '18 at 15:44
  • @ArtemBilan can you tell what should i try to do, should I handle those exceptions in the service activator itself? Also, sometimes i see that they reach ServiceActivator for [org.springframework.integration.handler.MethodInvokingMessageProcessor@687721e0] (errorLogger) received message: ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: nested exception is java.lang.Exception: Import failed, headers={history=errorChannel, id=39dee136-fb77-3109-c685-cd4957058861, timestamp=1544198126295}] – Chaitanya Reddy Dec 07 '18 at 15:53
  • We need to see a whole flow (https://docs.spring.io/spring-integration/docs/current/reference/html/system-management-chapter.html#message-history) which causes the error do not be sent to the `errorChannel`. As I said: your Source Polling Channel Adapter sends exceptions to `errorChannel`, but direct calls doesn't. You can consider to use `ExpressionEvaluatingRequestHandlerAdvice` for those cases: https://docs.spring.io/spring-integration/docs/current/reference/html/messaging-endpoints-chapter.html#message-handler-advice-chain – Artem Bilan Dec 07 '18 at 16:02
  • And don't put logs in comments - it's too hard to read - edit the question instead. – Gary Russell Dec 07 '18 at 16:18

0 Answers0