Warm tip: This article is reproduced from stackoverflow.com, please click
spring-integration transactions

How to work transactionally with spring-integration-smb

发布于 2020-04-22 11:05:45

I am new to the Spring Integration project. I am trying to process remote files (from an SMB2 share) transactionally with the spring-integration-smb project. With the help of this blog post I was able to process files transactionally (with Spring's PseudoTransactionManager) on the local filesystem. Now I've tried to adjust the sample to process files on a remote share (SMB), but I haven't found a solution to make to processing transactional. Have you any idea how I can implement such a transactional processing?

Questioner
Joe
Viewed
60
Artem Bilan 2020-02-07 02:22

You still can use similar approach with a PseudoTransactionManager and TransactionSynchronizationFactory combination to track your transaction statuses.

For rollback-kinda operations you can use an SmbRemoteFileTemplate to call its rename(), remove() etc. operations. The failed message contains for you all necessary info in the headers:

messageBuilder.setHeader(FileHeaders.REMOTE_HOST_PORT, uri.getHost() + ':' + uri.getPort())
                    .setHeader(FileHeaders.REMOTE_DIRECTORY, uri.getPath())
                    .setHeader(FileHeaders.REMOTE_FILE, uri.getFragment());