6

I was wondering if someone knows where I can see the data of a suspended message in the biztalk database.

I need this because about 900 messages have been suspended because of a validation and I need to edit all of them, resuming isn't possible.

I know that info of suspended messages are shown in BizTalkMsgBoxDb in the table InstancesSuspended and that the different parts of each message are shown in the table MessageParts. However I can't find the table where the actual data is stored.

Does anyone have any idea where this can be done?

SteveC
  • 15,808
  • 23
  • 102
  • 173
WtFudgE
  • 5,080
  • 7
  • 47
  • 59

4 Answers4

2

I found a way to do this, there's no screwing up my system when I just want to read them.

How I did it is using the method "CompressionStreams" using Microsoft.Biztalk.Pipeline.dll.

The method to do this:

    public static Stream getMsgStrm(Stream stream)
    {
        Assembly pipelineAssembly = Assembly.LoadFrom(string.Concat(@"<path to dll>", @"\Microsoft.BizTalk.Pipeline.dll"));
        Type compressionStreamsType = pipelineAssembly.GetType("Microsoft.BizTalk.Message.Interop.CompressionStreams", true);
        return (Stream)compressionStreamsType.InvokeMember("Decompress", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[] { (object)stream });
    }

Then I connect with my database, fill in a dataset and stream out the data to string, code:

        String SelectCmdString = "select * from dbo.Parts";
        SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(SelectCmdString, "<your connectionstring">);
        DataSet myDataSet = new DataSet();
        mySqlDataAdapter.Fill(myDataSet, "BodyParts");

        foreach (DataRow row in myDataSet.Tables["BodyParts"].Rows)
        {
            if (row["imgPart"].GetType() != typeof(DBNull))
            {
                SqlBinary binData = new SqlBinary((byte[])row["imgPart"]);
                MemoryStream stm = new MemoryStream(binData.Value);
                Stream aStream = getMsgStrm(stm);
                StreamReader aReader = new StreamReader(aStream);

                string aMessage = aReader.ReadToEnd();

                //filter msg
                //write msg
            }
        }

I then write each string to an appropriate "txt" or "xml" depending on what u want, you can also filter out certain messages with regular expression, etc.

Hope this helps anyone, it sure as hell helped me.

Greetings

WtFudgE
  • 5,080
  • 7
  • 47
  • 59
  • Anytime I write a .NET Tool to talk to BizTalk I always have to have it running on a BizTalk server where all the DLL's reside etc. In this solution, are you saying that I would only need to copy the Microsoft.Biztalk.Pipeline.dll to a server, or package it in my app and I could run my app anywhere using your method explained above? – Gareth Doherty Aug 21 '20 at 14:03
1

Extract Messages from suspended instances

Scenario:

BizTalk 2010 and SQL 2008 R2 is the environment we have used fore this scenario.

You have problem with some integrations, 1500 suspended instances inside BizTalk and you need to send the actual messages to a customer, and then you properly do not want to manually save out this from BizTalk Administrator.

There are a lot of blogs and Internet resources pointing out vbs, powershell scripts how to do this, but I have used BizTalk Terminator to solve this kind of scenarios.

As you now BizTalk terminator is asking you 3 questions when the tool starts

I.1.All BizTalk databases are backed up? II.2.All Host Instances is stopped? III.3.All BizTalk SQL Agents is stopped? This is ok when you are going to actually change something inside BizTalk databases but this is not what you are going to do in this scenario you are only using the tool to read from BizTalk databases. But you should always have backups off BizTalk databases.

You are always responsible for what you are doing, but when we have used this tools in the way I describe we have not have any problem with this scenario.

So after you have start Terminator tool please click yes to the 3 questions(you dont need to stop anything in this scenario) then connect to the correct environment please do this in your test environment first so you feel comfortable with this scenario, the next step is to choose a terminator task choose Count Instances(and save messages) after this you have to fill in the parameter TAB with correct serviceClass and Hostname and set SaveMessages to True and last set FilesaveFullPath to the correct folder you want to save the messages to.

Then you can choose to click on the Execute Button and depending of the size and how many it can take some time, after this disconnect Terminator do NOT do anything else.

You should now if you have filled in the correct values in the parameter TAB have the saved messages inside the FilesaveFullPath folder.

Download BizTalk terminator from this address:

http://www.microsoft.com/en-us/download/details.aspx?id=2846

0

This is more than likely not supported by Microsoft. Don't risk screwing up your system. If you have a need to have a edit and resubmit, it needs to be built into the orchestration. Otherwise, your best bet is to use WMI to write a script to:

  1. pull out all of the suspended messages
  2. terminate them
  3. edit them
  4. resubmit them
Christian Loris
  • 4,159
  • 1
  • 20
  • 29
  • So why the negative score? I'd be curious to hear what you're thinking is. – Christian Loris Mar 30 '10 at 14:55
  • I think when he answered his first line was targeted to you "there's no screwing up my system when I just want to read them"... – Nix Mar 30 '10 at 16:36
  • +1 for @ChrisLoris. The advice to use WMI and to terminate the suspended messages is sound. The other part of the advice is perhaps more formally put as "Microsoft does not support direct access to the BizTalk database. Future versions of BizTalk may change the schema, etc". With that in mind, consider that the solution given may need to be modified if a new production version or even a patch is installed. – Jennifer Zouak Mar 31 '10 at 12:06
  • Thanks for the feedback. I know, I hate the official 'Not Supported By MS' limit. There's alot you can get to under BizTalk's hood, but I've already been bitten a few times when getting support from MS. They don't turn into jerks or anything, but everytime thet hit an obstacle... the 'unsupported' action is always thrown out as a possibel reason. Just watch your back on this. I also did miss the read only comment in my reply. He just wants to do a bulk extract. Crticism accepted. – Christian Loris Apr 02 '10 at 14:36
0

you can find it through the HAT tool you just need to specify the schema ,port and the exact date with the exact time and it will show you the messages right click on the desired one and save .

Fahad
  • 1