The Death Bell for .Net Remoting

We attended a .Net User Group last night the .Net evangelist gave us quite an in depth overview of Web Service Extensions 2.0, 3.0, the history of WSI Web Service Interoperability Organisation (the guys who come up with the standards) and a sneak preview of Indigo.


Indigo looked very cool, quite a nice vision by Microsoft 3 lines of declarative code to enable queuing, transactions and security i.e. COM+, MSMQ, WS extn’s rolled into one. Not to mention the x number of lines of configuration xml one smart developer recognised would need to be in place … looks like Microsoft hasn’t been able to come up with mind reading software, the instructions still need to sit somewhere. Indigo should add a lot of value and ease of implementation to cross-machine\process boundary method calls.


How Indigo will integrate with BizTalk was touched on Indigo handling the message transport with BizTalk sitting atop it orchestrating the integration logic. See my post entitled The Future of BizTalk.  


The big surprise however was when we go to the section entitled “How should I make my applications Indigo ready”. There were basically two points here:


1)      Make sure your applications are loosely coupled and don’t expose any implementation logic outside their interfaces.


2)      Don’t use .Net Remoting as Indigo won’t support it (but will provide a replacement)


The second point brought a few gasps and giggles from the crowd present. When asked the Evangelist wasn’t sure .Net Remoting would be supported in future versions of the framework. The feeling I got from him was that Microsoft has made a decision to move away from this technology and that the System.Runtime.Remoting namespace is soon to be unsupported, defunct and be absent from future versions of the framework. So you ask what should we use until Indigo is released well MSMQ or Web Services was the answer.


R. Addis

Future of BizTalk

For those of you that attended the training and Tech Ed you may remember there was some confusion over the roles of BizTalk and the messaging engine Indigo built into LongHorn (MS future operating system due for release 2006).


I found this article based on a Scott Woodgate (a New Zealander and the godfather of BizTalk) presentation trying to clear this up. Well it looks like good news for Indigo and good news for the future of BizTalk unfortunately I feel that backward compatibility due to the large amount of underlying architectural change will be a problem but it’s still to soon to be sure.


The main points:



  • From a BizTalk perspective, Indigo is the vehicle that will provide secure, reliable transacted services (over more than just http).

  • Indigo is an API, BizTalk is a set of tools. Indigo will natively integrated into the next version of BizTalk after BizTalk 2004. The demos showed a prototype Indigo adapter that worked with BizTalk 2004.

  • BizTalk has been achieving reliable services through the BizTalk Framework 2. In future this will be deprecated and replaced with WS-ReliableMessaging, which will be provided by Indigo.

  • BizTalk will use the security model built into Indigo to enable WS-Security support for Username tokens and X509 certificates that can be easily configured through attributes, configuration files and policy.

The presentation helped me understand that Indigo is the plumbing. A lot of business functionality will require the use of tools that take advantage of that plumbing, such as BizTalk. So I was interested a few days later to see an announcement that the BizTalk Orchestration will ship as part of Indigo in Longhorn. As the article points out, BizTalk seems to debut features that eventually become part of the plumbing.


This should sure up business confidence in BizTalk’s future with Microsoft’s commitment to this product.


R Addis 24/12/2004


Missing Vocabulary API


Has anybody seen a Vocabulary API for the rule engine? No? That’s probably because it seems to either be on its way out or never made it in the first place. According tothe BizTalk SDKThe following objects are exposed by Microsoft(r) BizTalk(r) Server 2004, but are not used in BizTalk Server programming.” These include the following from the Microsoft.RuleEngine Namespace



  • Vocabulary

  • VocabularyDefinition

  • VocabularyDefinitionDictionary

  • VocabularyDictionary

  • VocabularyInfo

  • VocabularyInfoCollection

  • VocabularyLink

All under the heading of “Unsupported BizTalk Classes”. So, I guess that means not to use them! Our guys are in the middle of doing a Biztalk Proof of Concept with MS at Reading, so I hope to get an answer on this!

Real asynchronous vs. Simulated asynchronous

Abstract: In the asynchronous world, we can talk about Real async and Simulated async. Each one has its own pros and cons. Let’s see a simplified sample of each case.


Sample scenario, let’s assume two systems, A and B:
   1.-   A sends a message to B.
   2.-   B processes the request from A.
   3.-   B returns a response to A.


Constraint: The processing of the request (step 2) takes some unpredictable time, so we cannot afford A to have an open connection waiting for the response from B at step 3. We need an asynchronous model, but it can be a real async or simulated async.


Real Async
In a Real async scenario all the communications are one-way, fire-and-forget. A sends the request to B and closes the connection. Once the processing is finished, B starts a new connection with A and sends a new message, the response.


The characteristics are:



  • Each message goes in a true one-way communication.
  • Both client and server must implement listeners –> from the communications point of view, both are client and servers.
  • Both A and B must be aware of the other system’s endpoint.
  • Bandwidth and CPU are optimized, and there are no blocking points.

here is a sample picture. Arrows shows who start the communications:


Probably, the most important issue is the second point: both A and B are clients and servers (or consumers and providers). Both systems must implement a listener or message sink. This is not suitable in many cases when A is a client app. So we can go for a simulated async.


 


Simulated Async
In the simulated approach, almost all the communications are still one-way, but B never starts a new connection; instead, B just puts the response available for A. It’s A responsibility to get the response, doing some polling.


The characteristics are:



  • All the communications are started by A. B does not deal with communications issues. 
  • B is not even aware of A. If there are many As, B does not need to know.
  • Easy to implement. Or at least, easier than Real Async.
  • Bandwidth overload, because of the polling, as well some CPU consumption on A.

Here is the sample picture, modified showing simulated async via polling. Arrows shows who start the communications:


In this case, the response is not sent (PUT); it’s retrieved (GET), so it’s not a one-way communication.


These two models can extend to the infinite with many variations, but I think here are the two most basic ones.



 

Adding External Tools in Visual Studio for Installing/Removing assemblies to/from the GAC

First you open visual studio and goto Tools in the Menu bar and all the way towards the bottom of

the list you’ll see External Tools (click on that).

 

Once that is open you will see a list of Menu Contents, to the right you will see an add and delete button.  Click on the Add button.  Once that is done you will see a [New Tool 1] entry into the bottom of the list.

 


  • Fill out the Title (to your liking) For this sample I used ‘Install to GAC’ and ‘Remove from GAC’
  • For the Command Field, point to the gacutil.exe (by default in C:\Windows\Microsoft.NET\Framework\(latest version your compiling with)\gacutil.exe)
  • For VS 2005 by default gacutil.exe is “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe“
  • Arguments -i$(TargetPath) – This is a Visual Studio built-in macro. 
    -u$(TargetName) obviously for the removal process.


  • Now I prefer clicking on Use Output window so I can see the results of the gacutil output.

 

Now once you have that setup you can just select the project (from your solution explorer) and goto Tools and run the ‘Install to GAC’ or ‘Remove from GAC’ without going to the DOS prompt.

 

      -B

Forward Chaining ?

The BizTalk 2004 rules execution engine is “a discrimination network-based forward-chaining inference engine designed to optimize in-memory operation”. Apparently.


What I understand this to mean is that it can arrive at a decision based on reasoning of facts against conditions (inference), and that it reacts to new facts being “asserted” in a way which means that only rules which are relevant are re-examined (forward chaining). Facts get put into working memory. This triggers rules whose conditions match the new data. These rules then perform their actions. The actions may add new data/facts to memory, thus triggering more rules. And so on. The wikipedia has a pretty good summary.


 


Whilst this sounds pretty academic, it’s also important. Without understanding this, you can get yourself in a real buggers muddle – I’m proof of this! The rules engine has 3 stages to execution. The first stage is “matching” – if you’ve done some tracing of rules execution in the BRC this stuff will sound familiar. This stage checks its rules “conditions” against current “in memory” facts. These facts being loaded into memory are the “asserts” you see in the debug output. Once a condition is evaluated as true it gets added to the rule “agenda” (Agenda Update in the trace output). This is a sort of wait area until the engine has been through all the rules in the policy. Next stage is “Conflict Resolution” (don’t you just love that!). This is where the order of the rule firing is determined based upon the priority you have set for the rule. In the next “Action” stage, the actions of the rule are fired.


 


What’s important to remember here is that the “Action” stage could assert some more facts into memory. So what? Well to quote MSDN;


 


“Note that rule actions can assert new facts into the rule engine, which causes the cycle to continue. This is also known as forward chaining. It is important to note that the algorithm never pre-empts the currently executing rule. All actions for the rule that is currently firing will be executed before the match phase is repeated. However, other rules on the agenda will not be fired before the match phase begins again. The match phase may cause those rules on the agenda to be removed from the agenda before they ever fire. “


 


This is essentially what you would expect to happen I guess, but as most of the rules processing is done “behind closed doors” it can be hard to get a handle on what’s causing this type of effect. The tracing/debugging leaves a little to be desired. That’s where I’m off to next …

Optimize Thyself

OK, so tell me we haven’t all done this at least once. We come across a way to improve our output efficiency, and at the same time to enforce good design and standards – we figure we should provide the rest of the team with a tool that can help them achieve the same. We feel, for a small and fleeting moment, that warm glow.


 


Until someone comes along and points out a far better implementation of your optimisation, and delivers up a tool that’s more extensible, better integrated and (more importantly) finished. Don’t you just hate that?


 


Well you shouldn’t, and I don’t anymore. Bill Jones makes a good case for why you should be looking at CodeSmith 3.0 (Erics site was temporarily down when this was posted).


 


I found myself frequently writing the same CRUD code for my data layer objects. After looking at some great DAL generators (nTierGen.Net from Gavin Joyce is in my opinion one of the best), I threw together a DAL generator based around a code templating system. CodeSmith takes that idea and implements it beautifully. Really, take a look!

Resurfacing from Deep Dive

I’ve just attended the latest of the BizTalk Deep Dive training courses in the UK, which Quick Learn have developed, and are running with a special invite to Microsoft Partners. (I was lucky enough to get a place on one of the free sessions.)

The “entrance exam” for the course ensured all the delegates had a solid grasp of most of the product, and brought with them real world experience of BizTalk development. Ensuring this high-level of expertise on the course kept the discussions and questions at the appropriate level; also if you’re new to the product, you would quickly fall over in the hands-on sections.


The course coverage was broad as well as deep, going through the Share Point, WSE2, and SQL adapters, and also looking at Host Integration Server, and connecting to a DB2 database. Quite a lot of this stuff had been on my “To-do” list for months, and it was good to get a look at these areas of BizTalk that I had not touched yet.

One highlight for me was the in class discussions around complex aspects of the orchestration and messaging engine. These often went beyond the depth of the course notes, and I picked up a lot of info that’s just not documented or, as yet, blogged about. John Callaway, the instructor, has spent a lot of time with the key members of the BizTalk development team, and was able to answer almost all the questions we could throw at him, (usually someone on the course could chip in with some insight into the really tough ones).

If you are making the jump from intermediate to advanced BizTalk development, you should defiantly book yourself a place on one this course.

I also got the chance to take a beer with one of the BizTalk Bloggers, Chrostof Claessens, who was attending another training course at the center. It’s the first time I’ve met one of the contributors face-to-face, and good to be able to put a face to the name. I hope to get the chance to meet with all the contributors to the guide, one down, thirty to go…

Backup and Restore of your SQL resources (w/ sample automation scripts)

I am removing this post as it is no longer needed. With SP2 for 2004 public now, we have backported the Backup / Restore work from 2006 which includes scripts for automating the recovery of the system after a failure (which is what I had posted here). Those files are vbs scripts so there is no mystery as to what they are doing, and you should use them, following the DR instructions in our online docs.

 

Thx
Lee

Backup and Restore of your SQL resources (w/ sample automation scripts)

First, sorry I have disappeared for a while. I seem to say sorry a lot. We are pushing hard over here to build an awesome next version of the product and to fix up a number of things you guys have given us feedback on. I’m also still working on my Tech-Ed presentation so, well, life is busy in BizTalk world. However, that is no reason for me to not try and help your life be less busy. Here is a question I often hear posed and I thought I would give a couple of pointers.


BizTalk itself has a number of databases. The base engine has a mananagement database, a tracking database, a messagebox database. It also uses the SSO database and then you have BAM and BAS and HWS to add into the mix. When things go bad, and one of those databases goes down due to an unrecoverable hardware failure, you want to be able to restore the database to a new machine and get up and rolling quickly. There is actually some pretty decent documentation out there at http://www.msdn.microsoft.com/library/default.asp?url=/library/en-us/operations/htm/ebiz_ops_backuprestore_inpu.asp. This should walk you through what we do and why. Basically, because at times we use distributed transactions across our databases, we require the use of transactional log marking of the logs across our databases. Luckily we provide a sql agent job which you can configure to do this marking and backups for you. Note, configuring this should not be considered an option, but a must. Not only will you have no recovery story without backups, but our dbs are marked as recovery model full, so without doing the log backups, the log will grow forever and you will fall over from out of disk space errors. In SP1, we also included a feature to automate the log shipping so that you can have a warm backup. Docs for this are on http://download.microsoft.com/download/0/7/c/07c3598d-0f27-4d7d-a471-fad9b7da4fbd/Readme.htm. I wanted, though, to share a couple of sample vbs files which I have written to automate the updating of biztalk after you have restored the databases to a new set of servers.  One is for updating the databases. The other updates the registry. Both are driven by an xml file which will contain the information about which databases you moved and from where to where. If you did not move all of the database, but instead restored some in place and just rolledback to a point in the log, you don’t need to update them. The scripts are okay with you not putting all the databases in the .xml. However, make sure you get all databases into a consistent state. You don’t want to restore some and not others since we will then be out of sync. THESE ARE SAMPLES. You should try them out and make sure they work for you. I have actually only had a chance to try them out on the next release which we are working on, but since we have not changed the docs on how to restore, they’ll work for the 2004 too, but you need to test them and make sure. These are not “supported” but if you think you found an issue, let me know and I will update the file. The follow the steps outlined in the restoration process. Please read the docs and look at the scripts and test things out. In the next release, we will ship ones which look just like this as part of automating the restoration process, but I figured there is no point in not sharing them now since you have to do it now. Thx


So basically you would have a situtation where the hardware died and you needed to restore to a new machine, you would:


1)Make sure all bts related resources are turned off.


2) restore the databases to the new machines hopefully all you have to do is restore the last one if you were using our log shipping solution.


3) Fill in the xml script with the to and from values for all of your databases


4) Run the update registry script on each bts machine


5) Run the update database script on each machine


6) Turn everything back on and you are ready to go


Again, YOU SHOULD ALWAYS TRY THIS IN A TEST ENVIRONMENT. It would suck if you were in production and this issue hit you and you had never walked through what it took to restore and as such you realize that you had forgotten something which cost you. Test things so that you know how to do it if it ever occurs. Hope this stuff helps.


 


Thx


Lee


 


Each script takes one parameter which is the location of the .xml file which contains the update information.


UpdateDatabase.vbs


******************************************************************************************************


oldMgmtDBServer = “Not Specified”
oldMgmtDBName = “Not Specified”
newMgmtDBServer = “Not Specified”
newMgmtDBName = “Not Specified”
oldMasterMsgboxDBServer = “SubscriptionDBServerName”
oldMasterMsgboxDBName = “SubscriptionDBName”
newMasterMsgboxDBServer = “SubscriptionDBServerName”
newMasterMsgboxDBName = “SubscriptionDBName”
oldRuleEngineDBServer = “RuleEngineDBServerName”
oldRuleEngineDBName = “RuleEngineDBName”
newRuleEngineDBServer = “RuleEngineDBServerName”
newRuleEngineDBName = “RuleEngineDBName”
oldTrackingDBServer = “TrackingDBServerName”
oldTrackingDBName = “TrackingDBName”
newTrackingDBServer = “TrackingDBServerName”
newTrackingDBName = “TrackingDBName”
TrackingDatabaseMachineName = “TrackingDatabaseMachineName”
TrackingDatabaseName = “TrackingDatabaseName”
oldAnalysisDBServer = “TrackAnalysisServerName”
oldAnalysisDBName = “TrackAnalysisDBName”
newAnalysisDBServer = “TrackAnalysisServerName”
newAnalysisDBName = “TrackAnalysisDBName”
oldBamDBServer = “BamDBServerName”
oldBamDBName = “BamDBName”
newBamDBServer = “BamDBServerName”
newBamDBName = “BamDBName”
oldHWSAdminDBServer = “”
oldHWSAdminDBName = “”
newHWSAdminDBServer = “”
newHWSAdminDBName = “”



””””””’
Dim configObj, loaded, WshShell
Set configObj = CreateObject(“MSXML2.DOMDocument”)



Set WshShell = WScript.CreateObject(“WScript.Shell”)


configObj.async = false
loaded = configObj.load(WScript.Arguments(0))


if not loaded then
 wscript.echo “Failed to load the document: ” & configObj.parserError.reason
‘return the error string
end if


dim node : set node = configObj.selectSingleNode(“/UpdateConfiguration/ManagementDB”)
if not (node Is Nothing) then
 oldMgmtDBServer = node.getAttribute(“oldDBServer”)
 oldMgmtDBName = node.getAttribute(“oldDBName”)
 newMgmtDBServer = node.getAttribute(“newDBServer”)
 newMgmtDBName = node.getAttribute(“newDBName”)
else
 newMgmtDBServer = WshShell.RegRead(“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBServer”)
 newMgmtDBName = WshShell.RegRead(“HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBName”)
end if


set node = configObj.selectSingleNode(“/UpdateConfiguration/HWSAdminDB”)
if not (node Is Nothing) then
 oldHWSAdminDBServer = node.getAttribute(“oldDBServer”)
 oldHWSAdminDBName = node.getAttribute(“oldDBName”)
 newHWSAdminDBServer = node.getAttribute(“newDBServer”)
 newHWSAdminDBName = node.getAttribute(“newDBName”)
else
 On Error Resume Next
 newHWSAdminDBServer = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WebService\AdminDBServer”)
 if (err = 0) then
  newHWSAdminDBName = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WebService\AdminDBName”)
 end if
 
 newHWSAdminDBServer = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WMI\AdminDBServer”)
 if (err = 0) then
  newHWSAdminDBName = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WMI\AdminDBName”)
 end if


 On Error Goto 0
end if


set node = configObj.selectSingleNode(“/UpdateConfiguration/MessageBoxDB[@IsMaster=’1′]”)
if not (node Is Nothing) then
 oldMasterMsgboxDBServer = “‘” & node.getAttribute(“oldDBServer”) & “‘”
 oldMasterMsgboxDBName = “‘” & node.getAttribute(“oldDBName”) & “‘”
 newMasterMsgboxDBServer = “‘” & node.getAttribute(“newDBServer”) & “‘”
 newMasterMsgboxDBName = “‘” & node.getAttribute(“newDBName”) & “‘”
end if


set node = nothing
set node = configObj.selectSingleNode(“/UpdateConfiguration/TrackingDB”)
if not (node Is Nothing) then
 oldTrackingDBServer = “‘” & node.getAttribute(“oldDBServer”) & “‘”
 oldTrackingDBName = “‘” & node.getAttribute(“oldDBName”) & “‘”
 newTrackingDBServer = “‘” & node.getAttribute(“newDBServer”) & “‘”
 newTrackingDBName = “‘” & node.getAttribute(“newDBName”) & “‘”


 TrackingDatabaseMachineName = newTrackingDBServer
 TrackingDatabaseName = newTrackingDBName
end if


set node = nothing
set node = configObj.selectSingleNode(“/UpdateConfiguration/AnalysisDB”)
if not (node Is Nothing) then
 oldAnalysisDBDBServer = “‘” & node.getAttribute(“oldDBServer”) & “‘”
 oldAnalysisDBDBName = “‘” & node.getAttribute(“oldDBName”) & “‘”
 newAnalysisDBDBServer = “‘” & node.getAttribute(“newDBServer”) & “‘”
 newAnalysisDBDBName = “‘” & node.getAttribute(“newDBName”) & “‘”
end if


set node = nothing
set node = configObj.selectSingleNode(“/UpdateConfiguration/BamDB”)
if not (node Is Nothing) then
 oldBamDBServer = “‘” & node.getAttribute(“oldDBServer”) & “‘”
 oldBamDBName = “‘” & node.getAttribute(“oldDBName”) & “‘”
 newBamDBServer = “‘” & node.getAttribute(“newDBServer”) & “‘”
 newBamDBName = “‘” & node.getAttribute(“newDBName”) & “‘”
end if


set node = nothing
set node = configObj.selectSingleNode(“/UpdateConfiguration/RuleEngineDB”)
if not (node Is Nothing) then
 oldRuleEngineDBServer = “‘” & node.getAttribute(“oldDBServer”) & “‘”
 oldRuleEngineDBName = “‘” & node.getAttribute(“oldDBName”) & “‘”
 newRuleEngineDBServer = “‘” & node.getAttribute(“newDBServer”) & “‘”
 newRuleEngineDBName = “‘” & node.getAttribute(“newDBName”) & “‘”
end if


””””””’



wscript.echo “Attempting to connect to server “”” & newMgmtDBServer & “””, database “”” & newMgmtDBName & “””…”
dim cnString : cnString = “Driver={SQL Server}; Trusted_Connection=yes; Server=” & newMgmtDBServer & “; Initial Catalog=” & newMgmtDBName
dim MgmtDbConn : set MgmtDbConn = GetConnection(cnString)
dim MgmtDbCmd  : set MgmtDbCmd  = CreateObject(“ADODB.Command”)
set MgmtDbCmd.ActiveConnection = MgmtDbConn


wscript.echo “Updating the adm_Group table with new information”
MgmtDbCmd.CommandText = “Update adm_Group SET BamDBServerName = ” & newBamDBServer & “, BamDBName = ” & newBamDBName & “, TrackAnalysisServerName = ” & newAnalysisDBServer & “, TrackAnalysisDBName = ” & newAnalysisDBName & “, TrackingDBServerName = ” & newTrackingDBServer & “, TrackingDBName = ” & newTrackingDBName & “, SubscriptionDBServerName = ” & newMasterMsgboxDBServer & “, SubscriptionDBName = ” & newMasterMsgboxDBName & “, RuleEngineDBServerName = ” & newRuleEngineDBServer & “, RuleEngineDBName = ” & newRuleEngineDBName
wscript.echo MgmtDbCmd.CommandText
MgmtDbCmd.Execute


wscript.echo “Updating the list of messageboxes in the management database”
for each node in configObj.selectNodes(“/UpdateConfiguration/MessageBoxDB”)
 oldDBName = node.getAttribute(“oldDBName”)
 oldDBServer = node.getAttribute(“oldDBServer”)
 newDBName = node.getAttribute(“newDBName”)
 newDBServer = node.getAttribute(“newDBServer”)


 ‘ Perform the Update here


 MgmtDbCmd.CommandText = “Update adm_MessageBox set DBName = ‘” & newDBName & “‘, DBServerName = ‘” & newDBServer & “‘ WHERE DBName = ‘” & oldDBName & “‘ AND DBServerName = ‘” & oldDBServer & “‘”
 wscript.echo MgmtDbCmd.CommandText
 MgmtDbCmd.Execute


 MgmtDbCmd.CommandText = “Update TDDS_Sources set SourceName = ‘” & newDBServer & “_” & newDBName & “‘, ConnectionString = ‘Pooling=false;Current Language=us_english;Integrated Security=SSPI;Data Source=” & newDBServer & “;Initial Catalog=” & newDBName & “‘ WHERE SourceName = ‘” & oldDBServer & “_” & oldDBName & “‘”
 wscript.echo MgmtDbCmd.CommandText
 MgmtDbCmd.Execute
next


wscript.echo “updating the list TDDS Destinations with the new tracking database names”
set node = configObj.selectSingleNode(“/UpdateConfiguration/TrackingDB”)
if not (node Is Nothing) then
 oldDBName = node.getAttribute(“oldDBName”)
 oldDBServer = node.getAttribute(“oldDBServer”)
 newDBName = node.getAttribute(“newDBName”)
 newDBServer = node.getAttribute(“newDBServer”)
 
 MgmtDbCmd.CommandText = “Update TDDS_Destinations set ConnectionString = ‘Pooling=false;Current Language=us_english;Integrated Security=SSPI;Data Source=” & newDBServer & “;Initial Catalog=” & newDBName & “‘ WHERE ConnectionString = ‘Pooling=false;Current Language=us_english;Integrated Security=SSPI;Data Source=” & oldDBServer & “;Initial Catalog=” & oldDBName & “‘”
 wscript.echo MgmtDbCmd.CommandText
 MgmtDbCmd.Execute
end if



‘update  HWS_Core  in HWS Admin database
if ( (newHWSAdminDBServer <> “”) AND (newHWSAdminDBName <> “”) ) then
 wscript.echo “Attempting to connect to server “”” & newHWSAdminDBServer & “””, database “”” & newHWSAdminDBName & “””…”
 cnString = “Driver={SQL Server}; Trusted_Connection=yes; Server=” & newHWSAdminDBServer & “; Initial Catalog=” & newHWSAdminDBName
 dim HWSDbConn : set HWSDbConn = GetConnection(cnString)
 dim HWSDbCmd  : set HWSDbCmd  = CreateObject(“ADODB.Command”)
 set HWSDbCmd.ActiveConnection = HWSDbConn


 HWSDbCmd.CommandText = “Update HWS_Core set BizTalkServerLocation = ‘” & newMgmtDBServer & “‘,  BizTalkManagementDBName = ‘” & newMgmtDBName & “‘, TrackingDatabaseMachineName = ” & TrackingDatabaseMachineName & “, TrackingDatabaseName = ” & TrackingDatabaseName & “, ConstraintsDatabaseMachineName = ‘” & newHWSAdminDBServer & “‘, ConstraintsDatabaseName = ‘” & newHWSAdminDBName & “‘”
 wscript.echo HWSDbCmd.CommandText
 HwsDbCmd.Execute


end if


 


‘ ===============================================================
‘  GetConnection(cnString)
‘  This function accepts a connection string and opens
‘  a connection by using it. It returns the connection
‘  back
‘ ===============================================================
Function GetConnection(cnString)
    dim conn : set conn = CreateObject(“ADODB.Connection”)
    conn.ConnectionTimeout = 30
    conn.Provider = “MSDASQL”
    conn.Open cnString
    Set GetConnection = conn
End Function


***************************************************************************************************


UpdateRegistry


***************************************************************************************************


Dim configObj, loaded, WshShell
Set configObj = CreateObject(“MSXML2.DOMDocument”)



Set WshShell = WScript.CreateObject(“WScript.Shell”)


configObj.async = false
loaded = configObj.load(WScript.Arguments(0))


if not loaded then
 wscript.echo “Failed to load the document: ” & configObj.parserError.reason
 ‘return the error string
end if


On Error Resume Next


dim node : set node = configObj.selectSingleNode(“/UpdateConfiguration/ManagementDB”)
if not (node Is Nothing) then
 newDBServer = node.getAttribute(“newDBServer”)
 newDBName = node.getAttribute(“newDBName”)


 bKey = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBServer”)
 if (err = 0) then
  WScript.Echo bKey
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBServer”, newDBServer, “REG_SZ”
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Administration\MgmtDBName”, newDBName, “REG_SZ”
 end if
else
 wscript.echo “Management Database was not updated”


end if


set node = configObj.selectSingleNode(“/UpdateConfiguration/HWSAdminDB”)
if not (node Is Nothing) then
 newDBServer = node.getAttribute(“newDBServer”)
 newDBName = node.getAttribute(“newDBName”)
 
 bKey = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WebService\AdminDBServer”)
 if (err = 0) then
  WScript.Echo bKey
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WebService\AdminDBServer”, newDBServer, “REG_SZ”
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WebService\AdminDBName”, newDBName, “REG_SZ”
 end if
 
 bKey = WshShell.RegRead(“HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WMI\AdminDBServer”)
 if (err = 0) then
  WScript.Echo bKey
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WMI\AdminDBServer”, newDBServer, “REG_SZ”
  WshShell.RegWrite “HKLM\SOFTWARE\Microsoft\BizTalk Server\3.0\Hws\WMI\AdminDBName”, newDBName, “REG_SZ”
 end if
else
 wscript.echo “HWS Admin Database was not updated”
end if


*****************************************************************************************************


Sample .xml for driving these scripts. You should be editting this obviously. I just put the names of the dbs in here.


*****************************************************************************************************


<UpdateConfiguration>
 <MessageBoxDB oldDBName=”BizTalkMsgboxDb” oldDBServer=”asdf” newDBName=”BizTalkMsgboxDb” newDBServer=”fdsa” IsMaster=”1″/>
 <TrackingDB oldDBName=”BizTalkDTADb” oldDBServer=”asdf” newDBName=”BizTalkDTADb” newDBServer=”fdsa”/>
 <RuleEngineDB oldDBName=”BizTalkRuleEngineDb” oldDBServer=”asdf” newDBName=”BizTalkRuleEngineDb” newDBServer=”fdsa” IsMaster=”1″/>
 <BAMDB oldDBName=”BizTalkDTADb” oldDBServer=”asdf” newDBName=”BizTalkDTADb” newDBServer=”fdsa”/>
 <ManagementDB oldDBName=”BizTalkMsgboxDb” oldDBServer=”asdf” newDBName=”BizTalkMsgboxDb” newDBServer=”fdsa” IsMaster=”1″/>
 <HWSAdminDB oldDBName=”BizTalkDTADb” oldDBServer=”asdf” newDBName=”BizTalkDTADb” newDBServer=”fdsa”/>
</UpdateConfiguration>