Querying the WMI MSBTS_MessageInstance class

As I suppose not everyone reading my blog is reading the newsgroups on a daily basis, here's a highlight.  Today, a question came up regarding the querying of the MSBTS_MessageInstance class. 

Let's summarise what is possible with this WMI class:

  • Retreiving all message instances that are currently available in the message box.
  • Retreiving all message instances that comply with certain conditions and are currently available in the message box.
  • Saving any of those messages to the file system.

What is not possible with this class?

  • Saving or retreiving a message that is tracked.  Tracked messages are not handled in the same way as messages that are still resided in the message box.  If you want to save tracked message instances, you need to use the MSBTS_TrackedMessageInstance WMI class.  Please keep in mind, when doing this, that this class does *not* support enumeration.  You will need to use the MessageInstanceID in order to create an instance of it!

In addition, remember that it is not possible to use the MSBTS_MessageInstance class to make select queries based upon the content of the message context!  Why?  Message context is something dynamic and is not compiled into the WMI classes.  The message context is accessible on the class as an XML string though...  Making selects is only possible using the WMI properties on this class.  Like: ServiceName, ServiceInstanceStatus, ServiceInstanceID, ServiceClassId, ServiceClass...

If you'd like to see this class in action using real life code - please check out my pet project: the BizTalk Server 2004 Tracking Playground.

Happy coding!


  • A little project I've created, called the Suspended Queue Listener, uses MSBTS_MessageInstance

  • Martijn,


    I read this artricledo i understand correct that there is no way to query the hat for a context property,

    Do we really have to retrieve the message / context first.

    Maybe this is a fuzzy question so let me rephrase

    Is it possible to query the HAT and context of messages in a easy way ?

  • Hi Patrick,

    this is true. You need to retreive the message first and then retreive it's context. That context is only available as an XML String so querying it directly is not possible. (This would have required BizTalk Server to dynamically compile WMI classes - *that* would be funky!)

    Best regards!


Comments have been disabled for this content.