BTS Suspended Messaging Instances with PowerShell

BTS Suspended Messaging Instances with PowerShell

Continuing with my series on managing BizTalk Server with PowerShell, here’s a
new script that deals with suspended messaging service instances:

#

#
declare our parameters: the action to take, and an optional

#
path to save messages to

#

param(

   [string] $action=$(throw ‘need
action’),

   [string] $path=$(if ($action -eq
‘save’) {
throw ‘need
path’ })

)


 


 

#

#
get all suspended messaging service instances,

#
both resumable and not-resumable

#

function bts-get-messaging-svc-instances()

{

   get-wmiobject
MSBTS_ServiceInstance `

      -namespace
‘root\MicrosoftBizTalkServer’ `

      -filter
‘ServiceClass=4 and (ServiceStatus = 4 or ServiceStatus = 16)’

}


 

#

#
save the message associated to the

#
specified messaging Service Instance

#

function bts-save-message([string]$msgid)

{

   $msg =
get-wmiobject MSBTS_MessageInstance `

      -namespace
‘root\MicrosoftBizTalkServer’ `

      -filter
“ServiceInstanceID = ‘$msgid'”

   $msg.psbase.invokemethod(‘SaveToFile’,
(
$path))

   “Message
from ServiceInstanceID=$msgid saved.”

}


 


 

#

#
main script

#

switch ( $action )

{

   ‘list’
{

      bts-get-messaging-svc-instances
|

         fl
InstanceId, ServiceName, SuspendTime, HostName,

            ServiceStatus,
ErrorId, ErrorDescription

   }

   ‘save’
{

      bts-get-messaging-svc-instances
|

         %{
bts-save-message(
$_.InstanceID)
}

   }

}

If you run it with the ‘list’ action, you can get a nicely formatted list with the
more significant properties of any suspended messaging service instance:

>

 PS E:\Projects\BizTalk\PSScripts> .\bts-get-suspended-msgs -action
list InstanceId : {24FF0CAC-58F8-424C-BC49-6E1BD5045463} ServiceName : AttachmentRequestRP
SuspendTime : 20060902091027.000000-300 HostName : BizTalkServerApplication ServiceStatus
: 4 ErrorId : 0xc0c01680 ErrorDescription : The published message could not be routed
because no subscri bers were found. This error occurs if the subscribing orches tration
or send port has not been enlisted, or if some of th e message properties necessary
for subscription evaluation h ave not been promoted. Please use the Biztalk Administration
console to troubleshoot this failure. InstanceId : {0661221D-3C2F-4AD6-B952-099E02BD0E21}
ServiceName : AttachmentRequestRP SuspendTime : 20060902091045.000000-300 HostName
: BizTalkServerApplication ServiceStatus : 4 ErrorId : 0xc0c01680 ErrorDescription
: The published message could not be routed because no subscri bers were found. This
error occurs if the subscribing orches tration or send port has not been enlisted,
or if some of th e message properties necessary for subscription evaluation h ave
not been promoted. Please use the Biztalk Administration console to troubleshoot this
failure. 

Do notice the script filters out so that we only consider messaging service instances
and not others like a suspended orchestration, you can however very easily tweak the
script to show those as well as present a different set of properties for each instance.

You can also run the script with the ‘save’ action and provide a secondary ‘path’
argument to the script. In this case, the script will save any tracked messages associated
with the suspended messaging service instances into the specified folder:

PS E:\Projects\BizTalk\PSScripts> .\bts-get-suspended-msgs -action save
'c:\temp \ctt' Message from ServiceInstanceID={24FF0CAC-58F8-424C-BC49-6E1BD5045463}
saved. Message from ServiceInstanceID={0661221D-3C2F-4AD6-B952-099E02BD0E21} saved.
Message from ServiceInstanceID={9E661EE6-4599-4458-B370-179220D66CF1} saved. 

Enjoy!

SOAPException Maximum request length exceeded

Have you attempted to consume a web service just to see this message in return?  It turns out that ASP.NET by default permits web requests 4096kb or smaller to be sent up to a web server, which is a good thing.  To pass through anything larger than that you must follow these simple steps:

  • locate either the web.config or machine.config depending on how large you want the scope of the change. (machine.config obviously overriding the default on the entire machine.)
  • change the maxRequestLength parameter like so
  • <httpRuntime>maxRequestLength ="8192"</httpRuntime>

section of your config file to something in larger than 4096kb.

MS BRE: Two new posts – Using XPaths and handling Negation as Failure

I’ve published two Microsoft Business Rules Engine-related articles today (nothing like a long weekend in a hotel).


Negation-as-Failure and the Microsoft Business Rules Engine
http://geekswithblogs.net/cyoung/articles/90100.aspx
Negation can be a surprisingly problematic issue in the world of rules.   This article looks at one type of negation, generally referred to  as ‘negation as failure’ (NaF), and discusses the implications for the Microsoft Business Rules Engine (MS BRE).   In summary, we shall see that MS BRE fails to provide direct support for this type of negation, and as a consequence, the Microsoft Business Rule Language (MS BRL) is less expressive than it might otherwise be.   I also discuss a general approach to working around this lack of expressivity.


Using XPath to handling XML in the Microsoft Business Rules Engine
http://geekswithblogs.net/cyoung/articles/90102.aspx
I’ve begun to lose count of the number of times I have been asked to troubleshoot issues with the rules engine only to find that the problem is a lack of understanding of how XML facts are manipulated in rules.   XPaths are used to map the hierarchical data model of an XML document onto the relational model used by MS BRE.   This mapping layer is vital, and is fully controllable by the rule developer.   In order to use MS BRE effectively over XML data, you need to ensure you understand how XPath is used alongside your rules.

No support for ’Well Formed Xml’ and ’DTD’ in the Generate Schemas wizard ’out of the box’

While creating a schema using the ‘Generate Schemas’ wizard I noticed that the ‘Well Formed XML’ and ‘DTD’ wizards are not loaded by default. If you try and use one you’ll received the following error message:
WFX to XSD schema generation module is not installed. Execute C:\Program Files\Microsoft BizTalk Server 2006\SDK\Utilities\Schema Generator\InstallWFX.vbs to install the WFX […]

BTSReset with PowerShell

BTSReset with PowerShell

In a previous post I mentioned that you could work with the WMI interfaces in BizTalk
Server easier in PowerShell than you could with C#, and in a more interactive fashion.
Here’s something else I cooked while playing with the PowerShell RC1: A PowerShell
version of my BTSReset tool!

#

#
declare two switch parameters: -start and -stop

#

param([switch] $start,
[
switch] $stop)


 

#

#
get list of application hosts

#

function bts-list-apphosts

{

   get-wmiobject
MSBTS_HostInstance `

      -namespace
‘root\MicrosoftBizTalkServer’ `

      -filter
HostType=1

}


 

#

#
stop the given host

#

function stop-host($apphost)

{

   $hostname = $apphost.HostName

   if ( $apphost.ServiceState
-ne 1 )

   {

      “Stopping
Host $hostname …”

      $apphost.invokemethod(‘Stop’, $null)

   }

}


 

#

#
start the given host

#

function start-host($apphost)

{

   $hostname = $apphost.HostName

   if ( $apphost.ServiceState
-eq 1 )

   {

      “Starting
Host $hostname …”

      $apphost.invokemethod(‘Start’, $null)

   }

}


 

#

#
main script

#


 

if (
!(
$stop)
-and !(
$start)
)

{

   $stop = $true

   $start = $true

}


 

if ( $stop )

{

   bts-list-apphosts
| %{ stop-host(
$_)
}

}


 

if ( $start )

{

   bts-list-apphosts
| %{ start-host(
$_)
}

}

 

Here’s a few examples of running the tool from the PowerShell prompt:

PS E:\temp> .\bts-reset.ps1
Stopping Host BizTalkServerApplication …
Starting Host BizTalkServerApplication …

PS E:\temp> .\bts-reset.ps1 -stop
Stopping Host BizTalkServerApplication …

PS E:\temp> .\bts-reset.ps1 -stop

PS E:\temp> .\bts-reset.ps1 -start
Starting Host BizTalkServerApplication …

>

New BAM Content…

The BizTalk Server Developer Center has been refreshed with new BAM content.



  • Business Activity Monitoring (BAM) FAQ List
    Get answers to your most frequently asked questions about BAM.

  • Getting Started Developing with BAM: EventStreams
    As a BAM developer, you need to be familiar with concepts in BAM, such as activities, continuations, observation models, and references. You should also understand the differences between tracking and transactional Processing. This document describes the most common tasks for developers who want to instrument a business solution using the BAM APIs.

  • Code Sample: BAM and HAT Correlation
    This sample demonstrates how to use the enhanced BAM features, and how to customize BAM and HAT integration. This sample also includes a Windows Forms application customizing BAM and HAT integration for the sample BizTalk solution.

http://msdn.microsoft.com/biztalk/

Administering BizTalk with PowerShell: Part 1

Administering BizTalk with PowerShell: Part 1

As many of you know, BizTalk Server has a fairly extensive WMI object model you can
use to manage and run your BizTalk servers. As even more of you know, WMI is
a pain in the neck to work with from pretty much anywhere, particularly C#.

However, PowerShell does
make it a lot easier and actually even fun, since you can interactively execute and
test any WMI query you need to perfection! Given that, it will make a nifty complement
to working with BizTalk Server’s WMI model. Here’s something to open your appettite:
List your BizTalk Hosts on the local server:

$hosts = get-wmiobject MSBTS_HostInstance -namespace ‘root\MicrosoftBizTalkServer’
$hosts | sort HostName | ft HostName, HostType

I’ll demonstrate some more interesting options in later posts!