]> Bulk extracting tracked messages from BizTalk 🌐:aligrant.com

Bulk extracting tracked messages from BizTalk

Alastair Grant | Thu 23 Jan 2020

I have occasionally found when things go wrong with in BizTalk, sometimes it's easiest to get all your messages out and re-play them.  It should go without saying: YMMV (Your Mileage May Vary) - you really need to know your applications, how state is managed, and the knock-on impact to other systems by replaying messages.

Warnings aside, it can be useful, a quirky set of errors on a remote system and resuming your instances simply won't do it, being able to drop the original files in is sometimes a god-send.

BizTalk supports the notion of message-tracking, where it can, if enabled, store a copy of the message as it passes through BizTalk in the Health and Tracking database (BizTalkDTADb).  You generally query this database through the administration console when using "Tracked Messages".  If tracking is enabled, you can save out messages one at a time in the UI and saving them - a laborious task in any organisation that actually conducts any volume of business.

At this point I turn to a trusty console app that will pull out all the messages in-bulk, saving them to the file system for your viewing pleasure.  In a bit of a tidy up, I decided I should probably put the code for this online for the benefit of others.  So I've tidied up the code a little and published it to GitHub.

Source: Ox.BizTalk.TrackedMessageExtractor
Exe: extractmessages.exe

This is licensed under a MIT license, which basically means you're free to do whatever you like with this, personal or commercial, just don't expect it to work or any sympathy if you break something.


You need to feed it a text file of message ids (one per line), which will need you to query the BizTalkDTADb directly (as exporting data from the admin console is irritatingly difficult).

Something like:

SELECT TOP 10 [MessageInstance/InstanceID] FROM BizTalkDTADb..dtav_MessageFacts

Providing whatever where clauses you desire to pin down the messages you're interested in.  Pop those message ids into a text file and run the extractor, either interactively or via a single command such as:

extractmessages --in=messages.txt --out=.\

Code changes

Please record any issues on GitHub, but also please do fork and fix anything and request a pull for changes.

Breaking from the voyeuristic norms of the Internet, any comments can be made in private by contacting me.