Reputation: 455
I implemented a sftp-inbound-channel-adapter, and when an exception is handled , i should display a customized message.
I tried :
<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
auto-startup="true" channel="receiveChannel" session-factory="sftpSessionFactory"
local-directory="file:${directory.files.local}" remote-directory="${directory.files.remote}"
auto-create-local-directory="true" delete-remote-files="true"
filename-pattern="*.txt" >
<int:poller fixed-delay="${sftp.interval.request}"
max-messages-per-poll="-1" />
<int-sftp:request-handler-advice-chain>
<bean: class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpression" value="payload" />
<property name="successChannel" ref="afterSuccessDeleteChannel" />
<property name="onFailureExpression" value="payload.renameTo(new java.io.File(payload.absolutePath + '.failed.to.send'))" />
<property name="failureChannel" ref="afterFailRenameChannel" />
</bean>
</int-sftp:request-handler-advice-chain>
But an element
<int-sftp:request-handler-advice-chain>
is not accepted. Can you explain another solution?
Upvotes: 4
Views: 1760
Reputation: 174484
The request handler advice goes on some downstream component, not an inbound channel adapter.
You can add an error-channel
to the <poller/>
element. The message sent to the error channel will be an ErrorMessage
with the exception as a payload. If it's an exception on the downstream flow, the payload will be a MessagingException
with failedMessage
and cause
properties.
Add some component to consume the error messages.
Upvotes: 2