This will be a semi-fictitious case study. In using MOM 2005 to recover an errant SQL port. This scenario is common and I’ve been asked about it a lot. This approach is the simple meat and potatoes process. There are lots of areas that could be polished up but that kind of thing can clutter up an article with too much detail.
The basic steps will be as follows:
- Define a rule to detect the error condition
- Define a script to correct the error condition
- Wire up the script to the rule so that the rule cant trigger it.
Define a rule to detect the error condition
For whatever reason (network down, SQL down) the port was unable to commmunicate with SQL and BizTalk shut it down. This will create an event log entry similar to the following
Type:Error
EventID:5649
Source: BizTalk Server 2004/2006
The receive location “SQL://<sql name/info>” is shutting down. Details:”The error threshold has been exceeded. The receive location is shutting down.”
You will setup a MOM Rule to detect this condtion. This is not a total MOM tutorial so I won’t go over the details here, but the basic process is to create a new rule and use the criteria tab to specify as many details as possible from the above event log entry. Be sure the rule is using the application event log as a source.
Define a script to correct the error condition
I would normally like to use managed code, but it is nice to remove dependencies from the .NET framework version (i.e. 2.0 might not be installed) and I also like being able to issue changes without having to recompile. This is good and bad for several reasons I don’t want to get into. The script that I use targets a specific port and tries to enable it. The script (written in vbscript) is the following: (it is bacially a lift from the BizTalk SDK)
‘————————————————————————- Option Explicit EnableReceiveLocation “ReceivePort1”, “ReceiveLocation1”, “TRUE”
Sub EnableReceiveLocation(strReceivePortName, strReceiveLocationName, sEnable) ‘If Receive Location found, enable it, otherwise print error and end.
‘This subroutine deals with all errors using the WbemScripting object. Error descriptions If ( TypeName(objWMIError) = “Empty” ) Then Sub PrintUsage() |
Wire the script to the rule
You have to go to the Response tab of the rule and u