How to not let BizTalk Help Class Code cache a customize config file?
- I have a BizTalk 2006 R2 solution. It uses some C# code in the help class to do some calculation.
At some stage of the data processing, the C# code reads a xml config file from a fix directory and also overwrites some value in that config file.
But I found that after I manually changed some value in the config file, I have to restart BizTalk host instance to clean the cache of the config file.
I am wondering is there anyway to not let the config file be cached by BizTalk Help Class?
Also if I let BizTalk Help Class automatically overwrites the value in the config file before it is being read, will BizTalk still keep the cache of the config file?
Thank you.
Answers
In my openion, storing config values in SSO database would be the better option.
There is a very good article "Where do I store my custom configuration for a BizTalk solution". I would suggest you to please go thru the below link once........ You will have a better understanding.... Where you should store your config values?
http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx
Regards,
Abhijit
Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question- Marked As Answer byWen-Jun ZhangMSFT, ModeratorWednesday, November 04, 2009 9:41 AM
- Hi Xiao,
You original issue isn't a typical 'caching' case. The essential is that appSettings simply doesn't have the ability to notice file change notifications on the config file. In other words, dynamically changing .config and reloading isn't supported. An app restarting should be required.
So as you already tried, using database to store the config should be the correct approach for you.
Thanks.
Sincerely WenJun Zhang - MSFT Microsoft Online Community Support Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked As Answer byWen-Jun ZhangMSFT, ModeratorWednesday, November 04, 2009 9:41 AM
All Replies
- Hi,
This basically depens very much on how you read, write and cache the config file. Since you're using C# code you have many possibilities to implement this.
There must be a way to refresh the cache after writing to the config file. Can you post the relevant parts of your code?
HTH, Randal van Splunteren - http://biztalkmessages.vansplunteren.net - Please mark as answered if this answers your question. - I use a Config.cs file in the help class to map all the configuration tag in the xml config file at the fixed directory.
I access the value by doing something like if (Config.HasProcessed == "True") to detect the value
Each Tag defined in the xml config file has a local variable like a key in the Config.cs file. And I use the Get and Set method to read and write the value.
I am thinking if I move the config setting to a database table, would this solve the problem I have?
Thank you. In my openion, storing config values in SSO database would be the better option.
There is a very good article "Where do I store my custom configuration for a BizTalk solution". I would suggest you to please go thru the below link once........ You will have a better understanding.... Where you should store your config values?
http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx
Regards,
Abhijit
Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question- Marked As Answer byWen-Jun ZhangMSFT, ModeratorWednesday, November 04, 2009 9:41 AM
- Hi,Do you load your file every time? Or only once?Because if you would only load this once in say a static variable, then you have a caching problem.Kind regardsTim
Hi,
Do you load your file every time? Or only once?Because if you would only load this once in say a static variable, then you have a caching problem.Kind regardsTimAs the condition statement I show above, The Tag <HasProcessed> value e.g. "True" in the config file will be read every time BizTalk application receive a file to process. After some condition, the value would be changed to "False" by the BizTalk Application. For Testing, I manually change the value from true to false, but BizTalk keeps caching the value "True".Every time after the value in the config file is read, a local variable is created to keep the value during the process.
Yeah, I found that post before I started this question in the forum.In my openion, storing config values in SSO database would be the better option.
There is a very good article "Where do I store my custom configuration for a BizTalk solution". I would suggest you to please go thru the below link once........ You will have a better understanding.... Where you should store your config values?
http://geekswithblogs.net/michaelstephenson/archive/2008/05/25/122381.aspx
Regards,
Abhijit
Abhijit Mahato Please "Mark as Answer" if Post has Answered the QuestionStore the value in the SSO database, does that mean any database such as the database which is for this BizTalk application? Or it has to be the BizTalk application?If I store the value in a database table, would this solve the caching issue?If I store the value in a database table, would this solve the caching issue?
Yes.. If you store the value in a database table, you would not face the caching issue.
Regards,
Abhijit
Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question- Using a database to store config will only solve the caching issue by not caching. So every reference to the config value will require a database request for the config value. This replaces the cache concurrency issue with a potential performance issue.
If performance is not a problem then the database solution is fine, otherwise you will need to investigate a smarter caching mechanism e.g. NCache or the Enterprise Library Caching Block. I have used a lightweight caching mechanism that creates a FileWatcher on the config file. If the file every changes it reloads the cache. - I think the performance is not a problem for this BizTalk application.
It only reads one file to process everyday, and this configuration value only reads once for each file.
I am wondering in Visual Studio 2005, the Help Class project setting, is there anything could stop .Net caching? - I just tried that, it works.
But I don't understand, in the post Where do I store my custom configuration for a BizTalk solution , it also mentioned customized configuration file, so I guess it should work. I read the code, it is pretty much the same idea. So anyway knows why the one in the post it works, but the one I have not?
Thank you.
- Hi Xiao,If you want to use a .config file in a BizTalk solution. You have to use the BTSNTSvc.exe.configYou can store your values in there. Just don't forget this when you do the installation on a different server.Kind regardsTim
- Hi Xiao,
You original issue isn't a typical 'caching' case. The essential is that appSettings simply doesn't have the ability to notice file change notifications on the config file. In other words, dynamically changing .config and reloading isn't supported. An app restarting should be required.
So as you already tried, using database to store the config should be the correct approach for you.
Thanks.
Sincerely WenJun Zhang - MSFT Microsoft Online Community Support Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.- Marked As Answer byWen-Jun ZhangMSFT, ModeratorWednesday, November 04, 2009 9:41 AM
- In case you ever need to cache the results from the database or a config file, here is some sample code :)
Allows for refresh on a timer and/or a file change event
http://cid-4e9c10425c5f8e8f.skydrive.live.com/self.aspx/Public/SimpleCache.zip An alternative way of using database is to store the value in a seperate config file (not the BTSBTSVC.exe.config), it doesn't cache at all -- which avoids caching issue. It's almost the same idea of the database approach except that you don't have to deal with database. What I am not sure about is whether file locking could be an issue, it depends on the read/write frequency and concurrency.
Note: A seperate config file can be access by ConfigurationManager.OpenMappedExeConfiguration.
Linda

