Answered by:
Send notifiEcation on a Empty CSV file

Question
-
Hello Experts,
We will be receiving a CSV file and we will not be doing any transforms. But will have to check to check if its empty then we will have to send notification through email.
I am not sure how we will checking if the file is empty. Do we have to check for the row count. Any suggestion on this is greatly appreciated.
Thanks
Thursday, June 9, 2016 1:24 PM
Answers
-
In below link you can find the exact code
In your case you need to have a condition that if stream length =0 then construct a dummy message and send the dummy message to messagebox where any exception handler Orchestration can subscribe to the message.
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, June 15, 2016 4:22 PM
All replies
-
Refer: https://social.msdn.microsoft.com/Forums/en-US/a905ca26-fe0a-472a-bc08-83239ec26029/skipping-empty-flatfile-messages?forum=biztalkgeneral
Rachit Sikroria (Microsoft Azure MVP)
Thursday, June 9, 2016 1:29 PMModerator -
Do we need to create a pipeline component.Can this be done something like counting the number of rows in the incoming file in the map and check.
Thursday, June 9, 2016 1:32 PM -
Hold on, what exactly do you mean by "empty"?
No content at all? Header with no detail records? No file at all?
There's lot's of different kinds of 'empty'. How you handle it depends on which it is.
Thursday, June 9, 2016 1:35 PMModerator -
John, It is a CSV file which will have the headers with sometimes no records on it.If it has records I will have to do nothing and drop it in the destination. Notification needs to sent that there are no records in the file received.Thursday, June 9, 2016 1:41 PM
-
Do we need to create a pipeline component.Can this be done something like counting the number of rows in the incoming file in the map and check.
IMO, pipeline component will be the best place to handle this.
Refer for the code: https://social.msdn.microsoft.com/Forums/en-US/a905ca26-fe0a-472a-bc08-83239ec26029/skipping-empty-flatfile-messages?forum=biztalkgeneral
Rachit Sikroria (Microsoft Azure MVP)
Thursday, June 9, 2016 1:51 PMModerator -
Is there an definitive way to identify the existence of a record? Such s a specific TAG or header value that indicates the count of records?
If so, then a Custom Pipeline Component that peeks into the Stream looking for such an identifier would be best. You would only have to look as far as the position of the first record or header value. Do not read the whole stream into a string.
If no records are detected, set s custom Context Property you can use to route the empty message to an Orchestration or Send Port where you can create any Alert you need.
Thursday, June 9, 2016 2:35 PMModerator -
I dont think we will be having tag or header with the value that indicates the count of records.If so how can we achieve thisThursday, June 9, 2016 3:25 PM
-
Hi vdha, are you working with Sid_2014?Thursday, June 9, 2016 3:43 PMModerator
-
Yes. Johns.We have the same Requirement.Thursday, June 9, 2016 3:46 PM
-
Well, can you check? There has to some difference between the empty vs non-empty file.Thursday, June 9, 2016 4:20 PMModerator
-
Johns,
The File will have just header if it is an empty file. No specific TAG or header value that indicates the count of records. If I create two schemas one for the Header and the other one is Document Schema. If I disassemble the received Flat File, the Document schema will have nothing if we are receiving the file with no records other than header.
Is there a way to check if the Document schema is empty or not. If its empty only I will have to send the notification. Otherwise no changes.
Thanks
Wednesday, June 15, 2016 1:52 PM -
Hi,
File adapter deletes any file with 0 bytes . So what you are getting is more important before any suggestion .Check your file size if it is >0 bytes then only you can apply any logic .
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, June 15, 2016 4:01 PM -
It will not be the FILE adapter but we will be taking the data from the SFTP server. So how can I approach this scenario.Wednesday, June 15, 2016 4:09 PM
-
In below link you can find the exact code
In your case you need to have a condition that if stream length =0 then construct a dummy message and send the dummy message to messagebox where any exception handler Orchestration can subscribe to the message.
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, June 15, 2016 4:22 PM -
Hi Sid,
You have following option:
1) Custom Pipeline: After flat file disassembler you can have custom pipeline where u check the file size before processing. But if a custom pipeline component returns a null from the Execute(...) method, no exception will occur and effectively just "eat" the message. So, in case of null you would need to construct a dummy message and handle in orchestration.
2) Custom flat file disassembler: You can write your own flat file disassembler that uses the BizTalk flat file disassembler to process the messages. If the message happens to be empty, simply return dummy message in your first GetNext(...) method call and act accordingly in Orchestration to trigger an alert based on the message received.
3) Change at SFTP end: Let the files get SFTP'ed in the some different drop location. Then write a windows service which polls the drop location every once a while, picks the file and in case of a non-ZERO length file, posts it to the your configured drop location. This way the ZERO length files will not get picked up (in case of a deffer-ed write by the SFTP server they will show as non-ZERO files in a later pass and then get processed). Then the service could in case of a ZERO byte file send out an alert or email notification to stake holders..
Rachit Sikroria (Microsoft Azure MVP)
- Edited by Rachit SikroriaModerator Thursday, June 16, 2016 6:51 PM
Thursday, June 16, 2016 6:50 PMModerator