programming4us
 
Applications Server
 

BizTalk Server 2009 : Administrative Tools (part 2) - WMI

1/5/2013 11:50:04 AM

3. WMI

Windows Management Instrumentation provides a standard way of managing a computer system. WMI allows you to

  • Gather information about systems.

  • Configure systems.

  • Fire or consume specific WMI events occurring on c = omputers or servers.

Tables 11 and 12 describe the different BizTalk WMI classes and events. To utilize these classes, you must use the WMI COM API or the System.Management assembly, which is a .NET COM Interop assembly. Listing 1 demonstrates how to create a host using WMI API from managed code.

Table 11. BizTalk WMI Classes
WMI Class NameSpecific MethodsPurpose
MSBTS_AdapterSettingNoneRegisters new adapters.
MSBTS_DeploymentServiceDeploy, Export, Import, RemoveDeploys/undeploys assemblies and imports/exports binding files.
MSBTS_GroupSetting
RegisterLocalServer,
UnRegisterLocalServer

Represents information about BTS Groups.
MSBTS_HostStart, StopRepresents a host. Used to start/stop all host instances in a given BizTalk host. It is also used to get/set host properties.
MSBTS_HostInstance
GetState, Install, Start, Stop,
Uninstall

Represents a host instance. Used to install/uninstall and start/stop a specific host instance in a given BizTalk host.
MSBTS_HostInstanceSettingNoneRepresents host settings.
MSBTS_HostQueue
ResumeServiceInstancesByID,
SuspendServiceInstancesByID,
TerminateServiceInstancesByID

Resumes, suspends, or terminates service instances.
MSBTS_HostSettingNoneSets host settings.
MSBTS_MessageInstanceSaveToFileRepresents a message instance.
MSBTS_MsgBoxSettingForceDeleteRepresents a single Messagebox setting in the BizTalk Server Group.
MSBTS_Orchestration
Enlist, QueryDependencyInfo,
QueryInstanceInfo, Start,
Stop, Unenlist

Represents an orchestration. Used to start/stop and enlist/unenlist orchestrations.
MSBTS_ReceiveHandlerNoneRepresents a receive handler. Used to configure receive handlers.
MSBTS_ReceiveLocationDisable, EnableRepresents a receive location. Used to enable and disable the receive location.
MSBTS_ReceiveLocation
Orchestration

NoneRepresents all possible combinations of orchestrations and receive locations.
MSBTS_ReceivePortNoneRepresents a receive port. Used to configure receive ports.
MSBTS_SendHandlerNoneRepresents a send handler. Used to configure send handlers.
MSBTS_SendPortEnlist, Start, Stop, UnenlistRepresents a send port. Used to configure send ports.
MSBTS_SendPortGroupEnlist, Start, Stop, UnEnlistRepresents a send port group. Used to start/stop and enlist/unenlist send port groups.
MSBTS_SendPortGroup2
SendPort

NoneRepresents a many-to-many relationship between send port groups and send ports.
MSBTS_ServerCheckIfCanInstallHost Instances, Start, StopRepresents a computer within a BizTalk Server Group. Used to start services on a given server.
MSBTS_ServerHostForceUnmap, Map, UnmapRepresents a mapping between BizTalk hosts and host instances. Used to map and unmap relationships.
MSBTS_ServiceInstanceResume, Suspend, TerminateRepresents an instance of a service. Used to resume, suspend, and terminate services.
MSBTS_TrackedMessage
Instance

SaveToFileRepresents a tracked message instance saved in the Messagebox or Archive databases. Used to save a message to a file.

Table 12. BizTalk WMI Events
WMI Event NameSpecific PropertiesPurpose
MSTBS_MessageInstance
SuspendentEvent

ErrorCategory, ErrorDescription,
ErrorId, HostName, Message
InstanceID, MessageType,
ReferenceType, ServiceClass,
ServiceClassID, Service
InstanceID, ServiceTypeID

Represents a suspended event for a BizTalk Message Queuing (MSMQT) message instance
MSTBS_ServiceInstance
SuspendentEvent

ErrorCategory, ErrorDescription,
ErrorId, HostName, InstanceID,
ServiceClass, ServiceClassID,
ServiceStatus, ServiceTypeID

Represents a suspended event for a service instance

Example 1. Create Host Example Using Managed Code
[C#]
using System.Management;

      // Basic WMI operation - Create
      // sample to show MSBTS_HostSetting instance creation
      public void CreateHost(string ServerName, string HostName, int HostType,
string NTGroupName, bool AuthTrusted)
      {
         try
         {
            PutOptions options = new PutOptions();
            options.Type = PutType.CreateOnly;

            // Create a ManagementClass object and spawn a ManagementObject instance
            ManagementClass objHostSettingClass = new ManagementClass("\\\\" +
ServerName + "\\root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);
            ManagementObject objHostSetting = objHostSettingClass.CreateInstance();

            // Set the properties for the Host
            objHostSetting["Name"] = HostName;
            objHostSetting["HostType"] = HostType;
            objHostSetting["NTGroupName"] = NTGroupName;
            objHostSetting["AuthTrusted"] = AuthTrusted;

            // Creating the host
            objHostSetting.Put(options);
            System.Console.WriteLine(string.Format("The Host '{0}'has been
created successfully", HostName ));
         }
         catch(Exception ex)

					  

{
            System.Console.WriteLine("CreateHost - " + HostName +
" - failed: " + ex.Message);
         }
      }

The same example using VBScript instead of managed code is shown in Listing 2.

Example 2. Create Host Example Using VBScript
[VBScript]
Option Explicit
' wbemChangeFlagEnum Setting
const UpdateOnly = 1
const CreateOnly = 2
Sub CreateHost (ServerName, HostName, HostType, NTGroupName, AuthTrusted)
   On Error Resume Next
   Dim objLocator, objService, objHostSetting, objHS

   ' Connects to local server WMI Provider BizTalk namespace
   Set objLocator = Createobject ("wbemScripting.SwbemLocator")
   Set objService = objLocator.ConnectServer(ServerName,
"root/MicrosoftBizTalkServer")

   ' Get WMI class MSBTS_HostSetting
   Set objHostSetting = objService.Get ("MSBTS_HostSetting")

   Set objHS = objHostSetting.SpawnInstance_

   objHS.Name = HostName
   objHS.HostType = HostType
   objHS.NTGroupName = NTGroupName
   objHS.AuthTrusted = AuthTrusted

   ' Create Host
   objHS.Put_(CreateOnly)

   CheckWMIError
   wscript.echo "Host - " & HostName & " - has been created successfully"
end Sub

					  

Another interesting task you can accomplish with WMI is to subscribe to MSTBS_MessageInstanceSuspendentEvent and MSTBS_ServiceInstanceSuspendentEvent. Consuming these events will allow you to handle certain situations gracefully in your BizTalk solution. For instance, when a mapping error occurs on a send or receive port, you could decide to send an e-mail to an administrator and automatically terminate the service instance. Listing 3 shows how to subscribe to a WMI event.

Example 3. Subscribing to a BizTalk WMI Event
using System.Management;

static public void ListenForSvcInstSuspendEvent()
 {
     try
     {
        // Set up an event watcher and a handler for the
MSBTS_ServiceInstanceSuspendedEvent event
       ManagementEventWatcher watcher =
new ManagementEventWatcher( new ManagementScope("root\\MicrosoftBizTalkServer"),
new EventQuery("SELECT * FROM MSBTS_ServiceInstanceSuspendedEvent") );

        watcher.EventArrived += new EventArrivedEventHandler(MyEventHandler);

        // Start watching for MSBTS_ServiceInstanceSuspendedEvent events
        watcher.Start();

        Console.WriteLine("Press enter to quit");
        Console.ReadLine();
        watcher.Stop();
     }
     catch (Exception ex)
     {
        Console.WriteLine("Error: " + ex.Message);
     }
  }

  static public void MyEventHandler(object sender, EventArrivedEventArgs e)
  {
     // Print out the service instance ID and error description upon receiving
     // of the suspend event
     Console.WriteLine("A MSBTS_ServiceInstanceSuspendEvent has occurred!");
     Console.WriteLine(string.Format("ServiceInstanceID: {0}",
e.NewEvent["InstanceID"]));
     Console.WriteLine(string.Format("ErrorDescription: {0}",
e.NewEvent["ErrorDescription"]));
     Console.WriteLine("");
  }

					  

 
Others
 
- BizTalk Server 2009 : Administrative Tools (part 1) - BizTalk Administration Console, BTSTask
- Microsoft Dynamic GP 2010 : Understanding all of the financial information about an asset with Fixed Asset Details
- Microsoft Dynamic GP 2010 : Tracking Tangible Personal Property Tax information for Fixed Assets
- Managing Exchange Server 2010 : Archiving and compliancy (part 3) - Discovery, Litigation hold
- Managing Exchange Server 2010 : Archiving and compliancy (part 2) - Messaging Records Management
- Managing Exchange Server 2010 : Archiving and compliancy (part 1) - Exchange 2010 Archiving
- Managing Exchange Server 2010 : Role Based Access Control (RBAC)
- Active Directory Domain Services 2008 : Proactive Directory Performance Management (part 2) - Working with Windows System Resource Manager
- Active Directory Domain Services 2008 : Proactive Directory Performance Management (part 1) - Managing System Resources
- Microsoft Dynamic AX 2009 : Enterprise Portal - Enterprise Portal Development Tools, Developing Data Sets
 
 
REVIEW
 
- First look: Apple Watch

- 10 Amazing Tools You Should Be Using with Dropbox

- Sigma 24mm f/1.4 DG HSM Art

- Canon EF11-24mm f/4L USM

- Creative Sound Blaster Roar 2

- Alienware 17 - Dell's Alienware laptops

- Smartwatch : Wellograph

- Xiaomi Redmi 2
 
VIDEO TUTORIAL
 
- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

- How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
 
Popular tags
 
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
 
Top 10
 
- Setup Free Media Server To Stream Videos To DLNA Compatible TV, Xbox 360 & PS3 (Play Station 3)
- How To Install Android Market & Google Apps On Kindle Fire
- How To Make Ubuntu Look Like Windows 7
- How To Add A New Account in MS Outlook 2013
- Get Android & Mac OS X Style Gadgets For Windows 7 & Windows 8 With XWidget
- How To Activate Microsoft Office 2013
- How To Install Actual Facebook App On Kindle Fire
- How To Create, View And Edit Microsoft Office Files On Kindle Fire
- Download Attractive Business PowerPoint Templates For Free At SlideHunter
- How To Use And Enable Hibernate & Sleep Mode In Windows 8