You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Enhancement : Add prefix or suffix to file name while the file is getting streamed via SFTP #2955
I wanted to give a temporary filename to the file placed in remote server while it was getting streamed. I did not have any other option except renaming the file before and after reading the file. It will be very helpful to have a built-in feature to temporary rename file while streaming it.
changed the title [-]Add prefix or suffix to file name while the file is getting streamed via SFTP[/-][+]Feature Enhancement : Add prefix or suffix to file name while the file is getting streamed via SFTP[/+]on Jun 7, 2019
I think the issue is if there are multiple instances. The rename would prevent a second instance from finding a file that is already being fetched by another instance.
Right. Isn't that what we do with distributed MetadataStore in source filters and in the idempotent receiver as well?
What is the point to fetch the same file in another instance if it has been processed already?
Also it looks like with the -stream option we don't have a way to to rename file back automatically, unless we are going to abuse .setHeader(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE, session)...
I'm not against the feature, I just want to see if we indeed need it so strongly over and existing functionality, although I agree that idempotent receiver doesn't sound so obvious and simple here...
@sahilmalhotra92 Can you provide the exact use case for why you need this?
Also it looks like with the -stream option we don't have a way to to rename file back automatically, unless we are going to abuse .setHeader(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE, session)...
I don't think it's abuse, that header is defined as a Closeable; there's no reason we can't wrap the session in another Closable.
@sahilmalhotra92 Actually, for "advanced" cases like this, perhaps it would be better to just use the SftpRemoteFileTemplate directly in your code instead of the gateway...
template.rename(...);
template.get(pathToFile, inputStream -> ...);
template.rename(...); // or template.remove(...);
@garyrussell Currently I am renaming the file and renaming it once read, it is solving my purpose even. I was thinking it from nice to have feature if it doesn`t increase the overhead. I will surely replace the logic from fetching the file using SftpRemoteFileTemplate instead of the gateway.
I want to download the file from SFTP based on filename calling from rest call, is it possible to pick from based on file name? if Yes, please provide some examples.
Activity
[-]Add prefix or suffix to file name while the file is getting streamed via SFTP[/-][+]Feature Enhancement : Add prefix or suffix to file name while the file is getting streamed via SFTP[/+]artembilan commentedon Jun 10, 2019
I wonder if this is really going to be a robust solution since we just might not have
MVpermission on that SFTP side, only reading one.I would suggest to consider an
Idempotent Receiversolution for such a requirement: https://docs.spring.io/spring-integration/docs/current/reference/html/#idempotent-receiverThis way you won't process the same file again and will have some external tool like Redis to check that file has been processed.
If you need to release a file in the end after streaming, you are good to remove an entry from the
ConcurrentMetadataStorefor that processed file.Although I might not mind against
MVsolution if that is pretty simple and really brings enough value over existing approaches.Does it make sense?
garyrussell commentedon Jun 10, 2019
I think the issue is if there are multiple instances. The rename would prevent a second instance from finding a file that is already being fetched by another instance.
artembilan commentedon Jun 10, 2019
Right. Isn't that what we do with distributed
MetadataStorein source filters and in the idempotent receiver as well?What is the point to fetch the same file in another instance if it has been processed already?
Also it looks like with the
-streamoption we don't have a way to to rename file back automatically, unless we are going to abuse.setHeader(IntegrationMessageHeaderAccessor.CLOSEABLE_RESOURCE, session)...I'm not against the feature, I just want to see if we indeed need it so strongly over and existing functionality, although I agree that idempotent receiver doesn't sound so obvious and simple here...
garyrussell commentedon Jun 10, 2019
@sahilmalhotra92 Can you provide the exact use case for why you need this?
I don't think it's abuse, that header is defined as a
Closeable; there's no reason we can't wrap the session in anotherClosable.garyrussell commentedon Jun 10, 2019
@sahilmalhotra92 Actually, for "advanced" cases like this, perhaps it would be better to just use the
SftpRemoteFileTemplatedirectly in your code instead of the gateway...WDYT?
sahilmalhotra92 commentedon Jun 10, 2019
@garyrussell Currently I am renaming the file and renaming it once read, it is solving my purpose even. I was thinking it from nice to have feature if it doesn`t increase the overhead. I will surely replace the logic from fetching the file using SftpRemoteFileTemplate instead of the gateway.
sahilmalhotra92 commentedon Jun 14, 2019
Not sure if I need to close it or leave it like this.
garyrussell commentedon Jun 14, 2019
We can leave it open; I will put it on the backlog and we can revisit later if there is demand for it.
artembilan commentedon Oct 30, 2019
We had a similar ticket on JIRA for a while: https://jira.spring.io/browse/INT-4442
gopibalagala commentedon Jun 13, 2020
Hi Team,
Thanks.
artembilan commentedon Jun 15, 2020
@gopibalagala ,
your question is not related to this ticket.
Please, use StackOverflow for the proper question-answer interaction.
Nevertheless your goal could be achieved via
SftpOutboundGatewayand itsGET.See more info in docs: https://docs.spring.io/spring-integration/docs/current/reference/html/sftp.html#sftp-outbound-gateway