none
Query Regarding BizTalk FTP Adapter RRS feed

  • Question

  • Hi All, 
    I have a project where client wants to BizTalk read a particular SQL table for file name and then file is pulled from FTP Server to local server. There would be more than 20000 files will be there at FTP location.
    ..so i was thinking can i query FTP location so that i retrive only those file which i got through SQL table..
    how can i make dynamic orchestration ..

    Pls Advise
    Sandeep
    Thursday, November 12, 2009 7:00 AM

Answers

  • With the out-of-the-box Microsoft BizTalk Adapters (file, ftp, etc.) this is not possible.


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, November 13, 2009 10:18 AM

All replies

  • Do you have any control over the file names and the FTP server, i.e. can you stretch the requirements a little bit? 
    For example, marking "seen"/processed files with some postfix(or prefix) or using the whole ftp folder as input(i.e. deleting all files) and leaving "unmatched" files in another special ftp folder.


    The "solutions" to your original tight requirements that I can think of are not nice but maybe they'll somehow help anyway:

    1) You can try modifying receive location properties (in particular, file mask property of the FTP adapter) programmatically from the orchestration). However, this will most likely not work (I suspect there is a limitation on the length of file mask property value which you would easily exceed with 20000 files)

    2) Have the orchestration receive files (i.e. delete them) and send "unmatched" ones to the same ftp folder. This way the unmatched files will indefinitely circulate through BizTalk which is also a nasty thing. Moreover, there will be some lag between deleting unmatched file and putting it back, so other application or user might not see files that should be there.

      

    Kiryl Kavalenka My Blog
    Thursday, November 12, 2009 8:06 AM
  • Hi ,
    Thanks for your reply.
    Can u pls clear my understanding ..
    when using FTP adapter will it consumes the file(i.e delete them )
    as client wants that i should read the copy of file the files should be there in FTP location..

    Thanks
    Sandeep
    Thursday, November 12, 2009 8:19 AM
  • Yes, that's right. FTP adapter deletes the file after receiving it. Otherwise, it would receive same messages over and over again. 

    As I said, it would me much easier if you could rename files slightly to mark their state.

    Kiryl Kavalenka My Blog
    Thursday, November 12, 2009 8:41 AM
  • Hi ,
    I am configuring FTP receive port but it gives warning C:/inetpub/ftproot does not exists.

    I gave folder property as inetpub/ftproot and to access i gave username and password
    i set file mask property as *.csv 

    What could be the reason..

    Thanks
    Sandeep

    Thursday, November 12, 2009 11:13 AM
  • FTP adapter would be looking for ftp://XXXXXXXXXX type of addresses.
    If you'd like to point to a local folder, you could also use FILE adapter and point that to the folder in question.


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Thursday, November 12, 2009 12:09 PM
  • Hi All,
    If i want file retained on ftp location after reading ..

    How can i achieve this..

    Pls Advise
    Sandeep
    Friday, November 13, 2009 8:06 AM
  • With the out-of-the-box Microsoft BizTalk Adapters (file, ftp, etc.) this is not possible.


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, November 13, 2009 10:18 AM
  • Hi Sandeep,

    You need to create a custom pipeline component to archive the recieve and send file. The pipeline component will be at Decode and Encode stages.
    You could do multiple things like you can dynamically create the file location for archiving, can assign the custom name to inbound and outbound files.
    Here is the code which could help you.

     

    Public Function Execute(ByVal Context As IPipelineContext, ByVal InMsg As IBaseMessage) As IBaseMessage _
    Implements Microsoft.BizTalk.Component.Interop.IComponent.Execute
    Try
    If InMsg.BodyPart IsNot Nothing Then
    ' Set the archive path & file name 
    _archiveFilePath = "Put your archive path"
    ' Wrap original stream in a Forward Only Event Stream (FOES) and 
    ' configure the read-event. 
    Dim dataStream As Stream = InMsg.BodyPart.GetOriginalDataStream()
    Dim eventingStream As New CForwardOnlyEventingReadStream(dataStream)
    AddHandler eventingStream.ReadEvent, AddressOf StreamOnReadEvent
    ' Assign FOES wrapper back to the BodyPart. 
    InMsg.BodyPart.Data = eventingStream
    End If
    Catch ex As Exception
    ' Log an exception, but do not raise. (An archive error will not prevent the message from being processed)
    System.Diagnostics.EventLog.WriteEntry(EVENT_LOG_SOURCE, String.Format("An error occured creating the archive file at {0}.{1}{2}The following error was raised: {3}", _archiveFilePath, Environment.NewLine, Environment.NewLine, ex.Message), EventLogEntryType.Error, DirectCast(ArchiveFileWriteFailures.GeneralException, Int32))
    End Try
    Return (InMsg)
    End Function

    Vishnu
    Friday, November 13, 2009 11:43 AM