none
Send Port File with Filters. wildcard on File.ReceivedFileName property

    Question

  • Hi all,

    I searched about one hour on google in order to know the way how to insert a wildcard in the Value field of Filters configuration.
    I explain more in details:
    I want to create a file sorting. I receive a file in C:\Input folder and depending on the name of the file, I want send this file to a specific folder.
    Sample: ITA123.txt is sent to C:\Input so BizTalk pick up the message and sends it to C:\ITA. Another file ITA456.txt is sent to C:\Input so BizTalk pick up the message and sends it to C:\ITA. Another file SPA789.txt is sent to C:\Input so BizTalk pick up the message and sends it to C:\SPA.

    I created one receive port and one receive location listening on C:\Input with file mask *.txt.
    I created two send ports, one that sends the file to C:\ITA and another one to C:\SPA. 
    Now I'm going to configure the Filters on both send ports. The FileName in input can be different, so it can be ITA123.txt, or ITA456.txt and so on, so I have to use a wildcard in order to subscribe the relative port to this files.
    I saw that in the Operator there isn't the "like" operator. I tried to insert in Value property ITA*.txt, or ITA%.txt, also with " char, but it is not working.

    Someone could help me?

    Thanks to everyone!

    Massimo

    Massimo
    Monday, November 02, 2009 4:42 PM

Answers

  • Hi,

    Just configuring the filters:
           BTS.ReceivePortName=myReceivePortName
                      AND
           File.ReceivedFileName=FileName1.xml (sample: ITA*.txt)
    will not work.

    After doing a quick check I found that, BTS.ReceivedFileName is available in the message context properties but not promoted. So you cannot use this in the send port filter.

    One option is there:

    -- Write a custome pipline component that will extract the filename from the FILE.ReceivedFileName and promotes this into your own property. Now you can use this property into the send port filter.

    Hope this will solve your problem.

    Regards,
    Abhijit
    Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question
    Tuesday, November 03, 2009 8:30 AM
  • Hi,

    1.  In the destination schema add one more field called desttype
    2.  Use a mapper with substring functoid to take first 3 char and store to dest schema in desttype field
    3.  ensure that desttype is promoted
    4.  now filter based on destype in sendport

    Now the real ques is how to get filename in mapper

    see this for the same

    http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/4397b185-11c8-4a01-872f-2b0a151e2513


      

    Vijaykishan | http://v2attechhorizon.blogspot.com | Please mark this as answer if it helps
    Tuesday, November 03, 2009 8:38 AM

All replies

  • Hi Massimo,

    Have you try create one receive port without filters and set a filter on each Send Port
    Bts.ReceivePortName=myReceivePortName
    AND
    File.ReceivedFileName=FileName1.xml (sample: ITA*.txt)


    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Monday, November 02, 2009 5:12 PM
    Moderator
  • I don't want to create a Receive port for each file type, but one receive port and one send port per file type.
    I could create two Receive Port with one Receive Location for each port with file mask set to ITA*.txt and SPA*.txt and one Send Port for each file type with the BTS.ReceivedPortName filter, one set to the first port and another one set to the second port.

    I like the solution to create one receive port and one receive location, then one send port per file Type, but this requires that in the filters I have to insert a sort of wildcard in order to pickup files filename that starts with ITA or SPA.

    Is it possible with BizTalk using only the BizTalk Admin Console?

    Massimo
    Monday, November 02, 2009 5:22 PM
  • Yes,

    Create one receive port (*.txt), and create one send port per file type, but config them with two filters:
    Bts.ReceivePortName=myReceivePortName
    AND
    File.ReceivedFileName=FileName1.xml (sample: ITA*.txt)
    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx
    Monday, November 02, 2009 5:29 PM
    Moderator
  • Hi,

    Just configuring the filters:
           BTS.ReceivePortName=myReceivePortName
                      AND
           File.ReceivedFileName=FileName1.xml (sample: ITA*.txt)
    will not work.

    After doing a quick check I found that, BTS.ReceivedFileName is available in the message context properties but not promoted. So you cannot use this in the send port filter.

    One option is there:

    -- Write a custome pipline component that will extract the filename from the FILE.ReceivedFileName and promotes this into your own property. Now you can use this property into the send port filter.

    Hope this will solve your problem.

    Regards,
    Abhijit
    Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question
    Tuesday, November 03, 2009 8:30 AM
  • Yes,

    Create one receive port (*.txt), and create one send port per file type, but config them with two filters:
    Bts.ReceivePortName=myReceivePortName
    AND
    File.ReceivedFileName=FileName1.xml (sample: ITA*.txt)
    Sandro Pereira - http://sandroasp.spaces.live.com/blog/ http://www.devscope.net/WhatWeDo/Integration/tabid/107/Default.aspx

    You cannot have wildcards or Regular expressions in the send port filter. I am not aware of this.
    Secondly my proposed solution would be below and I think it works.

    Create receive ports for each file type. Create wildcards for each file type for e.g. ReceivePortITA with wildcard ITA*.txt. This port will pick up files with ITA prefix from the Input folder. In similar way create receive ports for each file types.

    Now the problem is with the send ports, if you create only one send port it would be subscribed to only one file type. Remember you can only create filter over the receiveportname and not the received filename because you cannot use wildcards or RE in filter expressions. Therefore you have to create send ports for each file types which would be subscribed according to receiveportname and would place file in its own folder.
    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this as answer if it helps
    Tuesday, November 03, 2009 8:33 AM
  • Hi,

    1.  In the destination schema add one more field called desttype
    2.  Use a mapper with substring functoid to take first 3 char and store to dest schema in desttype field
    3.  ensure that desttype is promoted
    4.  now filter based on destype in sendport

    Now the real ques is how to get filename in mapper

    see this for the same

    http://social.msdn.microsoft.com/Forums/en-US/biztalkgeneral/thread/4397b185-11c8-4a01-872f-2b0a151e2513


      

    Vijaykishan | http://v2attechhorizon.blogspot.com | Please mark this as answer if it helps
    Tuesday, November 03, 2009 8:38 AM
  • I set:
    BTS.ReceivePortName == ReceiveFile AND
    FILE.ReceivedFileName == ITA*.txt (I tried also with complete path c:\Input\ITA*.txt and also including double " char "c:\Input\ITA*.txt")

    The stange thing is that also it is not working without wildcard!!
    So BTS.ReceivePortName == ReceiveFile AND FILE.ReceivedFileName == ITA123.txt or c:\Input\ITA123.txt or "ITA123.txt" or "c:\Input\ITA123.txt" is not working!
    I think that I'm missing something, but I don't know where...this is a simple BizTalk app!! :(

    Massimo
    Tuesday, November 03, 2009 8:43 AM
  • Hey Massimo,

    Please follow my last post.

    BTS.ReceivedFileName is available in the message context properties but not promoted. So you cannot use this in the send port filter.


    Regards,
    Abhijit
    Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question
    Tuesday, November 03, 2009 8:45 AM
  • Hi,

    I tried a sample for the same. I will explain how i did.

    1.  Add addl field desttype in the source schema
    2.  Promote the field
    3.  Get File.ReceivedFileName and store it in a temp message using construct message - Message Assignment
    4.  In the same construct shape use a transform shape
    5.  In the mapper use string extract functoid and store only ITA - SPA kind of to the desttype field of final destination message
    6.  Now that u have a final message with promoted field destype containing SPA / ITA you can filter as u wish.


    Vijaykishan | http://v2attechhorizon.blogspot.com | Please mark this as answer if it helps
    Tuesday, November 03, 2009 9:47 AM
  • Many thanks to everyone for your solutions!

    As I said before, I want to use only the Administration Console, so the solution is the one I wrote in the third post and reproposed by Abdul Rafay. 
    I saw in Admin Console that in fact the property File.ReceivedFileName is available but not promoted.

    I will try to use the solution proposed by Abhijit Mahato and BizTalkGhost.

    Thanks another time to everyone!

    Massimo


    Massimo
    Tuesday, November 03, 2009 1:34 PM