- BTSNTSVC config. A per server configuration is possible in this but I think it's best to avoid using such a file.
- Business rule policy which determines the local machine name then sets the database server based on this. A bit overkill.
- Business rule vocabulary with static value we can use. Doesn't work too well for different environments.
- Fact Retriever which will pull the value from somewhere else.
Considering that the database being used is on the same server/instance as the Biztalk databases, I opted to use the Fact Retriever to pull the database/instance configuration from the windows registry.
using System.Data.SqlClient;
using Microsoft.RuleEngine;
using Microsoft.Win32;
namespace My.BRE
{
public class AssertSiteConverterDB : IFactRetriever
{
public object UpdateFacts(RuleSetInfo ruleSetInfo, RuleEngine engine, object factsHandleIn)
{
object factsHandleOut;
if (factsHandleIn == null)
{
object servObj = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\BizTalk Server\\3.0\\Administration", "MgmtDBServer", ".");
SqlConnection SQLConn = new SqlConnection("Data Source=" + servObj.ToString() + ";Initial Catalog=SIP;Integrated Security=SSPI;");
DataConnection RulesConn = new DataConnection("my database", "my table", SQLConn);
factsHandleOut = RulesConn;
engine.Assert(factsHandleOut);
}
else
factsHandleOut = factsHandleIn;
return factsHandleOut;
}
}
}
Gac this and configure your policy to use this Fact Retreiver and this will ensure that the correct database/instance will be asserted no matter which environnment you deploy to.