| Karel Fuka 2006-08-16, 7:24 am |
| Hi there
we have used File Adapter coming with Biztalk SDK for our special
client's requirements and it worked without any issue in Biztalk 2004.
After migrating to Biztalk 2006, we started to see very peculiar
behaviour (I need to stress out that for Biztalk 2006 I tried both the
old 2004 version of this adapter and also the new SDK version coming
with BTS 2006 in:
"Microsoft BizTalk Server 2006\SDK\Samples\AdaptersDevelopment\Fil
e
Adapter"
What it does is that after processing the file, it does not delete it
sometimes, but sometimes it does. The error in the Application log is
self explaining and means that the file cannot be deleted because it is
locked (or is open).
When I digged into this and debugged code, I found that there is a
FileStream open for this file at the beginning. When processing is
finished (by calling 'SubmitSuccess' method), its 'Close' method is
called, but then the following 'File.Delete' cannot delete the file as
it remains open. But I can delete it manually afterwards.
When I went even more deeply into this, I found that stream's Close
operation is called, but 'Filemon.exe' does not always show 'Closed'
operation before 'File.Delete' operation is called, but sometimes it
does).
I made some workaround so we are OK with now, but I still would like
some clarification as I did not really find the real cause of this
problem:
1) Every Stream's Close operation should close immediately, i.e. it
should remove all handlers/locks on the underlying resources (sockets,
files). Am I right?
2) If so, could underlying Pipelines run in a different thread and
could hold file open for a fraction of time, so sometimes this thread
finishes processing before File.Delete is open, but sometimes it does
not and then file remains undeleted though it can be deleted without
any problems afterwards? But why Close() operation does not close file
anyway?
(Just more technically: Close() operation is called in SubmitSuccess
method in ReceiveBatch.cs. Maybe BTS 2006 calls this method prior to
finishing pipeline processing!???)
Any insight into inner workings of this is welcome. Also I would like
to hear from Microsoft when this issue will be fixed. Many thanks in
advance!
Regards,
Karel F.
|