locked
Save a text file in database through ReceivePort RRS feed

  • Question

  • I want to send a text file to a location through receive port and want to save same text file in  database through same receive port.

    What approach should I used ?

    Should I use two disassembler component one for sending file to a location and one for send the same file to database or It can be done by a single component ?



    Prakash





    • Edited by Shivay_ Wednesday, September 17, 2014 1:38 PM
    Wednesday, September 17, 2014 1:12 PM

Answers

  • Here is an article which explains the step required to achieve this:

    Using the BizTalk WCF-SQL Adapter to load a flat file into a SQL Server

    Along with this, you can also consider options like enabling tracking in the send port (if the requirement is to track the message you have send)

    Or create archive pipeline component which would save the flat file.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by Shivay_ Thursday, September 18, 2014 9:50 AM
    Wednesday, September 17, 2014 1:42 PM
  • If you can create the solution without using orchestrations you have already avoided one of the biggest performance problems.

    There is also a performance penalty on running a custom pipeline, and in this case you are also limiting the performance of both the file delivery and the SQL process, if you try to do them both at once. If you use the send port group the error handling in case of a high load or deadlock etc is managed by the Biztalk automaticly.

    If you are really concerned about the performance you can create a custom WCF-service that will do the tasks you defined. By using Biztalk there is at least one trip to messagebox-database and back more than a custom service needs to handle. This will take maybe approx ~0.05-0.1s. This duration is a wild guess based on earlier experiences.

    Of course it can be done:

    - You can call for example a procedure from the pipeline. This is no different than creating an SQL Query in C#. Of course you need to assign the message in the stream to the sql query. You can use for example pipeline property, SSO, configuration files or registry to store the connection string.

    - You can define a parameter for the file location in a similar manner as above, and store the file on the fileshare by using a seekable stream and streamwriter.

    So basicly you can decide if you want to do the log to fileshare or to db, and if you want to do it in receive or send port. 

     
    • Marked as answer by Shivay_ Thursday, September 18, 2014 9:52 AM
    Thursday, September 18, 2014 9:13 AM

All replies

  • Here is an article which explains the step required to achieve this:

    Using the BizTalk WCF-SQL Adapter to load a flat file into a SQL Server

    Along with this, you can also consider options like enabling tracking in the send port (if the requirement is to track the message you have send)

    Or create archive pipeline component which would save the flat file.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by Shivay_ Thursday, September 18, 2014 9:50 AM
    Wednesday, September 17, 2014 1:42 PM
  • Hi Prakash,

    Use a SendPortGroup instead of a single SendPort. You can run 'n' number of send ports under 1 SendPortGroup.

    Then change your Orchestration configuration to bind to the new SendPortGroup rather than the one SendPort.

    Following links can help you to understand the working of SendPortGroup better:

    http://msdn.microsoft.com/en-us/library/aa561472.aspx

    http://msdn.microsoft.com/en-gb/library/aa559279.aspx

    Regards,

    Rachit

    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Proposed as answer by Pavan05 Wednesday, September 17, 2014 2:09 PM
    • Unproposed as answer by Pavan05 Wednesday, September 17, 2014 2:39 PM
    Wednesday, September 17, 2014 1:45 PM
    Moderator
  • Thanks Ashwin for your reply.

    But my actual requirement is as follows:

    I am getting a file in receive location and I want to send that file to a repository location as well as want to save that file in database ? I want to done this  through custom disassembler ?


    Prakash

    Wednesday, September 17, 2014 1:51 PM
  • Prakash,

    Yes as said you can create archive pipeline like component through which would save/archive the flat file.


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Wednesday, September 17, 2014 1:53 PM
  • Can you give me some link by which I can get my requirement.

    I want to save that text file in database as well as in a repository location in my system .


    Prakash

    • Proposed as answer by Pavan05 Wednesday, September 17, 2014 2:09 PM
    • Unproposed as answer by Pavan05 Wednesday, September 17, 2014 2:10 PM
    Wednesday, September 17, 2014 1:56 PM
  • Hold on, first, why do you need to save the file to a repository?  BizTalk can automatically store the incoming data if you enable Tracking on the Port.

    Either way, no a custom Disassembler specifically is probably not what you want.

    Wednesday, September 17, 2014 2:09 PM
    Moderator
  • Can I used the following approach:

    Create a custom decoder convert stream into string and then in decoding save that string in database .

    It is feasible or not ?


    Prakash

    Wednesday, September 17, 2014 2:14 PM
  • You can achieve it in following way. This is kind of archive functionality. 1) Create a receive location to pick the file. 2) Create a Send Port Group and subscribe it to the above ReceivePort by adding filters 3) Create two Send Ports and add these to the Send Port Group you created already a) One Send Port to submit data to Database using WCF-SQL adapter b) Other Send Port to save file to file location.

    Thanks, Pavan MCTS-Microsoft Biztalk Windows Server 2010

    Wednesday, September 17, 2014 2:14 PM
  • Dear Pavan,

    My actual requirement is as follows:

    I am getting a file in receive location and I want to send that file to a repository location as well as want to save that file in database ? I want to done this  through only  custom disassembler .


    Prakash

    Wednesday, September 17, 2014 2:30 PM
  • Please explain why you want to write the file to a repository. There are other, often better ways to address this.

    Again, you could use a custom disassembler, but it's highly unlikely that's you best option.

    Wednesday, September 17, 2014 2:45 PM
    Moderator
  • Hi John,

    You are right that it is not good idea to write the file to a repository through custom disassembler but we can write the file in db through custom disassembler.

    Because if we use sql adapter,it will decrease our performance .


    Prakash

    Wednesday, September 17, 2014 3:06 PM
  • What specific 'performance' issue are you having?  Keep in mind, everything decreases performance so it's all relative.

    Unless you have a historically demonstrated performance constraint or are experiencing a specific issue right now, don't worry about it.

    Build the app using standard BizTalk practices, including the SQL Adapter.  Then you can address anything that actually happens,
    Wednesday, September 17, 2014 3:29 PM
    Moderator
  • I don't understand, why do you want to use the receive port for sending? Please, explain.

    The simplest way is to receive by receive port and then send received messages to any number of send ports. In your case - two send ports: File and SQL.

    Anyway your messages from the RP go to the MessageBox, so you use SP as subscribers to those messages. As simple as that.


    Leonid Ganeline [BizTalk MVP] <a href="http://social.technet.microsoft.com/wiki/contents/articles/20258.biztalk-integration-development-architecture.aspx">BizTalk Development Architecture</a>

    Wednesday, September 17, 2014 8:48 PM
    Moderator
  • If you can create the solution without using orchestrations you have already avoided one of the biggest performance problems.

    There is also a performance penalty on running a custom pipeline, and in this case you are also limiting the performance of both the file delivery and the SQL process, if you try to do them both at once. If you use the send port group the error handling in case of a high load or deadlock etc is managed by the Biztalk automaticly.

    If you are really concerned about the performance you can create a custom WCF-service that will do the tasks you defined. By using Biztalk there is at least one trip to messagebox-database and back more than a custom service needs to handle. This will take maybe approx ~0.05-0.1s. This duration is a wild guess based on earlier experiences.

    Of course it can be done:

    - You can call for example a procedure from the pipeline. This is no different than creating an SQL Query in C#. Of course you need to assign the message in the stream to the sql query. You can use for example pipeline property, SSO, configuration files or registry to store the connection string.

    - You can define a parameter for the file location in a similar manner as above, and store the file on the fileshare by using a seekable stream and streamwriter.

    So basicly you can decide if you want to do the log to fileshare or to db, and if you want to do it in receive or send port. 

     
    • Marked as answer by Shivay_ Thursday, September 18, 2014 9:52 AM
    Thursday, September 18, 2014 9:13 AM