biztalkbiztalk-2010biztalk-2013

Monitor the "active state" of Biztalk send port service instance


Team,

My biztalk send port instance gets hung and stays in the active state for longer periods of time. I would like to monitor that send port active instance with the help of C#. I intend to run a code which will check if the send port(passed as a parameter) is still in a running state or not. Can anyone help me with that piece of code ?


Solution

  • Use WMI MSBTS_ServiceInstance.ServiceStatus Property:

    public static int GetRunningServiceInstanceCount()
    {
        int countofServiceInstances = 0;
        try
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "SELECT * FROM MSBTS_ServiceInstance WHERE ServiceStatus = 1 or ServiceStatus = 2");
            countofServiceInstances = searcher.Get().Count;
            return countofServiceInstances;
        }
        catch (ManagementException exWmi)
        {
            throw new System.Exception("An error occurred while querying for WMI data: " + exWmi.Message);
        }
    }
    

    To get to your actual problem: The SFTP adapter in BizTalk 2016 has a great way of using the most recent version of the FTP code. This might solve stability issues.

    Assuming from your BizTalk 2013 tag, you're probably not using the 2016 version, in that case double check you are at least at CU3 since that one solves a few critical SFTP bugs.