posted on Monday, August 01, 2005 3:37 PM
by
Benjy
BTS Diary 6 - The 1st Commandment
If there isnt one yet, there should be, namely,"Thou shalt study ALL the samples that Microsoft has given thee".
Strewth! I found a SchemaResolver component in the SDK samples that matched my requirements 99%. It demonstrates a technique where we can peek into the contents of the message and dynamically select a schema from a list based on what we find. In the specific case of the sample, the first two characters of the message determined which schema, but of course this can be changed to whatever logic is applicable to us.
Initially before finding the sample, i was playing around with SchemaWithNone() and found that the answer to my own question yesterday namely "what does the SchemaFromType() method [demonstrated in Gilles weblog" return? is "STRING". Thats very strange. Dont know why it didnt even compile first time around. Once i managed to change the DocumentSchema, i got a little stuck since i had written the code in the Disassemble method and didnt know exactly how to call the flat file disassembler to continue its execution. As a result, the ouput of the pipeline was in the same native format that it arrived! Anyhow, alls well that ends well.
To summarise, Its a common requirement to have multiple flat files (of different schemas) arriving at the same location, or have multiple recieve locations being handled by the same pipeline. In order to pick up the corresponding schema, there are two methods
(1) Stick a series of FF Disassemblers in the Disassemble stage. BTS will utilise a probing technique and find out which one to use (This is quoted direct from the SDK document. I need to test this out)
(2) Probe the message and find out which schema to use. Create a SchemaWithNone("ResultSchemaName") object and assign it to the DocumentSchema. [If you use the Pipeline Component Wizard, which is really awesome, it will create a disassembling component for you and SchemaWithNone can be set as one of the design time properties"]. Once you have assigned the schema, dont forget to call the disassembler. Take a look at the SDK sample or Gilles post on "selecting a flat file schema dynamically" , for code blocks that achieve this.
Just to add one more thing and reinforce what I said earlier, the Pipeline Component Wizard is really neat. Great work Martijn.