BizTalk Server General - BT 2004: accessing messages in suspended queue

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > June 2004 > BT 2004: accessing messages in suspended queue





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author BT 2004: accessing messages in suspended queue
Edwin King

2004-06-09, 8:31 am

Greetings,
I've been scanning these fora for some hints to my problem; but nothing seems to
fit.

The scenario is that we need to access messages in the "suspended q" (like the old versions)
programmatically. We would like to be able to move those messages elsewhere at some point.

I have not been able to find any clear way to do this (asside from hitting the MsgBoxDb via SQL).
Does anyone have any pointers/hints about this?

TIA,
Edwin King
Monah Khalil [MSFT]

2004-06-09, 8:31 am

This code snippet might be helpful. Please remember this is just a sample
presented as is and needs to be modified for your specific requirements. To
save messages you need to access them using WMI:

public void DumpToDisk()
{
ManagementBaseObject[] m_moMessageInstances;
ManagementObjectSearcher m_mgMISearcher;

FileStream fs = new FileStream(m_sOutputFolder + "\\index.txt",
FileMode.Create, FileAccess.Write);
String sMessage = "";

String sQuery = "SELECT * FROM MSBTS_MessageInstance where
HostName=\"BizTalkServerApplication\""; // and (ServiceClass = 1 or
ServiceClass = 4 or ServiceClass = 64 )";
WqlObjectQuery oqObjectQuery = new WqlObjectQuery(sQuery);

ManagementNamedValueCollection moContext = new
ManagementNamedValueCollection();
moContext.Add("IterationDelayMS", 10);

m_mgMISearcher = new ManagementObjectSearcher(oqObjectQuery);

m_mgMISearcher.Scope = new
ManagementScope("root\\MicrosoftBizTalkServer");
m_mgMISearcher.Options.Context = moContext;
m_mgMISearcher.Options.ReturnImmediately = true;

m_moMessageInstances = new
ManagementBaseObject[m_mgMISearcher.Get().Count];

m_mgMISearcher.Get().CopyTo(m_moMessageInstances, 0);
Console.WriteLine(m_moMessageInstances.Length);
foreach (ManagementObject iMessage in m_moMessageInstances)
{
try
{
sMessage = iMessage.Properties["MessageInstanceID"].Value.ToString() +
"\r\n";
fs.Write(Encoding.ASCII.GetBytes(sMessage), 0,
Encoding.ASCII.GetByteCount(sMessage));
ManagementBaseObject inParams =
iMessage.GetMethodParameters("SaveToFile");
inParams["OutputFolderFullPath"] = m_sOutputFolder;
ManagementBaseObject outParams = iMessage.InvokeMethod("SaveToFile",
inParams, null);
}
catch(Exception e)
{
Console.WriteLine("Error: " + e.Message);
}
}
fs.Flush();
fs.Close();
}



--
Thanks,

Monah
Microsoft Corporation
http://www.microsoft.com
--
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
"Please do not send email directly to this alias. This is our online account
name for newsgroup participation only."


"Edwin King" <tkdotnet@hotmail.com> wrote in message
news:12BF5F60-40F1-4A90-BD87-8AE9BFC3DE06@microsoft.com...
> Greetings,
> I've been scanning these fora for some hints to my problem; but nothing
> seems to
> fit.
>
> The scenario is that we need to access messages in the "suspended q" (like
> the old versions)
> programmatically. We would like to be able to move those messages
> elsewhere at some point.
>
> I have not been able to find any clear way to do this (asside from hitting
> the MsgBoxDb via SQL).
> Does anyone have any pointers/hints about this?
>
> TIA,
> Edwin King



Edwin King

2004-06-11, 5:43 pm

Thanks for the info, Monah. It has been a big help. We had looked at the WMI classes a little; but were hoping for a .Net api. But we'll use whatever gets the job done as usual ;)

Edwin King

"Monah Khalil [MSFT]" wrote:

> This code snippet might be helpful. Please remember this is just a sample
> presented as is and needs to be modified for your specific requirements. To
> save messages you need to access them using WMI:
>
> public void DumpToDisk()
> {
> ManagementBaseObject[] m_moMessageInstances;
> ManagementObjectSearcher m_mgMISearcher;
>
> FileStream fs = new FileStream(m_sOutputFolder + "\\index.txt",
> FileMode.Create, FileAccess.Write);
> String sMessage = "";
>
> String sQuery = "SELECT * FROM MSBTS_MessageInstance where
> HostName=\"BizTalkServerApplication\""; // and (ServiceClass = 1 or
> ServiceClass = 4 or ServiceClass = 64 )";
> WqlObjectQuery oqObjectQuery = new WqlObjectQuery(sQuery);
>
> ManagementNamedValueCollection moContext = new
> ManagementNamedValueCollection();
> moContext.Add("IterationDelayMS", 10);
>
> m_mgMISearcher = new ManagementObjectSearcher(oqObjectQuery);

> m_mgMISearcher.Scope = new
> ManagementScope("root\\MicrosoftBizTalkServer");
> m_mgMISearcher.Options.Context = moContext;
> m_mgMISearcher.Options.ReturnImmediately = true;
>
> m_moMessageInstances = new
> ManagementBaseObject[m_mgMISearcher.Get().Count];
>
> m_mgMISearcher.Get().CopyTo(m_moMessageInstances, 0);
> Console.WriteLine(m_moMessageInstances.Length);
> foreach (ManagementObject iMessage in m_moMessageInstances)
> {
> try
> {
> sMessage = iMessage.Properties["MessageInstanceID"].Value.ToString() +
> "\r\n";
> fs.Write(Encoding.ASCII.GetBytes(sMessage), 0,
> Encoding.ASCII.GetByteCount(sMessage));
> ManagementBaseObject inParams =
> iMessage.GetMethodParameters("SaveToFile");
> inParams["OutputFolderFullPath"] = m_sOutputFolder;
> ManagementBaseObject outParams = iMessage.InvokeMethod("SaveToFile",
> inParams, null);
> }
> catch(Exception e)
> {
> Console.WriteLine("Error: " + e.Message);
> }
> }
> fs.Flush();
> fs.Close();
> }
>
>
>
> --
> Thanks,
>
> Monah
> Microsoft Corporation
> http://www.microsoft.com
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> You assume all risk for your use.
> © 2003 Microsoft Corporation. All rights reserved.
> "Please do not send email directly to this alias. This is our online account
> name for newsgroup participation only."
>
>
> "Edwin King" <tkdotnet@hotmail.com> wrote in message
> news:12BF5F60-40F1-4A90-BD87-8AE9BFC3DE06@microsoft.com...
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com