locked
Custom adatper to rename files RRS feed

  • Question

  • We want to develop a custom adapter which can listen for a specific file mask(A_original.txt) on a folder and renames it to another(A_rename.txt) on the same folder. These are huge files. So we would need a windows rename action(not stream through BizTalk)
    We would like BizTalk to just capture the event of 'file creation' and rename it. Upon receiving event, BizTalk will invoke a process which will process the file. I have a use case to handle and need help to understand if this is feasible with BizTalk.
    Thursday, March 1, 2012 6:28 PM

Answers

  • There is a sample file adapter in the BizTalk SDK Samples directory, I would take this sample and change the .net code to rename the file, create the message that you want to send into BizTalk and test.


    Bill Chesnut | BizTalk Server MVP | Mexia Consulting | Melbourne Australia
    http://www.biztalkbill.com
    Please indicate "Mark as Answer" if this post has answered the question.

    Saturday, March 3, 2012 5:40 AM
  • Hi,

    We had a kind of similar requirement. I would suggest you should proceed as below. I am assuming that you have got the orchestration in place.

    1- Write a .NET component to rename the file. As a best practice You should archive both the files, Old File as well as New File. 

    2- Call the component inside the orchestration to rename the file.

    3- After renaming the file send the file to other location. Let the other orchestration pick up the file and do the business process.

    You can also do this at the send port. Just change the source file name and drop it at another location.

    Regards,

    Vishnu


    Best Regards, Vishnu

    Saturday, March 3, 2012 7:40 AM

All replies

  • Hi

    Why you would need Biztalk here?

    I would do following:

    • create a .net windows service which will keep on polling the folder location and rename the file. the .net service would be able to watch the folder and catch the event when the new file will be created.
    • This blog can give you some idea about watching a folder .net. 

    I hope that helps!

    HTH,Naushad (MCC/MCTS) http://alamnaushad.wordpress.com,My New Technet Wiki Article “BizTalk Server: Performance Tuning & Optimization"

    If this is helpful or answers your question - please mark accordingly! Please "Vote As Helpful" if this was useful while resolving your question!

    Thursday, March 1, 2012 6:36 PM
    Moderator
  • Hi Naushad, thanks for your reply.

    However, we noticed that the file system watcher does not behave when network connectivity is lost and restored. It still ran as if nothing had happened but it could not recognize any more events. sue ?

    I was reading on MSDN that "Once the network connection is reestablished, the file system watcher will not pick up new events."

    Thursday, March 1, 2012 6:53 PM
  • Ok, In that case you would need to extend the service to be some more intelligent. I would still not use Biztalk to do this Job. I would still go and use .net and SQL to make an intelligent windows service to achieve it.

    We would need to consider many cases while writing the service. the one would be network connectivity as you have explained.

    HTH,Naushad (MCC/MCTS) http://alamnaushad.wordpress.com,My New Technet Wiki Article “BizTalk Server: Performance Tuning & Optimization"

    If this is helpful or answers your question - please mark accordingly! Please "Vote As Helpful" if this was useful while resolving your question!

    Thursday, March 1, 2012 6:59 PM
    Moderator
  • Why you would need Biztalk here?


    We would need Biztalk to orchestrate the rest of the processes in the flow. We were wondering how BizTalk can be triggered by the creation of the large file. To clarify, we will not be using BizTalk just to rename the file, but to kick of the remaining processes in the workflow.
    Thursday, March 1, 2012 9:18 PM
  •  Ok, Seems I have missed that one! Thanks for more information. !

    IMO a standalone service will be better to rename and copy the file to a different location from where BizTalk will pick it up and process it further!

    Or could write some scripts to do that, Please refer this script on technet,Might be helpful!

    HTH,Naushad (MCC/MCTS) http://alamnaushad.wordpress.com,My New Technet Wiki Article “BizTalk Server: Performance Tuning & Optimization"

    If this is helpful or answers your question - please mark accordingly! Please "Vote As Helpful" if this was useful while resolving your question!

    Thursday, March 1, 2012 10:28 PM
    Moderator
  • The thing is, whatever is monitoring for new files, needs to let BizTalk know that a file has been created. BizTalk will not pick up the file at all.
    Thursday, March 1, 2012 11:28 PM
  • Hi

    Just to get some more insights of the requirement, What is the purpose behind rename of file ? 

    I would do following:

    if my Requirement is :

    • A file comes to folder FolA in format A_Old.txt
    • My windows watcher service will keep on monitoring FolA and when a file comes it will rename it to A_new.txt and moves to a folder FolBiz
    • I will configure a receive location to poll FolBiz with the file mask *_new.txt to receive any incoming file

    I hope that helps!

    HTH,Naushad (MCC/MCTS) http://alamnaushad.wordpress.com,My New Technet Wiki Article “BizTalk Server: Performance Tuning & Optimization"

    If this is helpful or answers your question - please mark accordingly! Please "Vote As Helpful" if this was useful while resolving your question!


    Thursday, March 1, 2012 11:38 PM
    Moderator
  • There is a sample file adapter in the BizTalk SDK Samples directory, I would take this sample and change the .net code to rename the file, create the message that you want to send into BizTalk and test.


    Bill Chesnut | BizTalk Server MVP | Mexia Consulting | Melbourne Australia
    http://www.biztalkbill.com
    Please indicate "Mark as Answer" if this post has answered the question.

    Saturday, March 3, 2012 5:40 AM
  • Hi,

    We had a kind of similar requirement. I would suggest you should proceed as below. I am assuming that you have got the orchestration in place.

    1- Write a .NET component to rename the file. As a best practice You should archive both the files, Old File as well as New File. 

    2- Call the component inside the orchestration to rename the file.

    3- After renaming the file send the file to other location. Let the other orchestration pick up the file and do the business process.

    You can also do this at the send port. Just change the source file name and drop it at another location.

    Regards,

    Vishnu


    Best Regards, Vishnu

    Saturday, March 3, 2012 7:40 AM