Powershell script to administer messages in BizTalk

The below script does everything from resume to terminate the suspended messages. It also allows you to get counts and save suspended messages into dedicated folders.

# Script to save, resume and list suspended messages. To be used by BizTalk admin ONLY!
# Created on 30/01/2014 by Dipesh A.
# Commands:
   # Note: CD to script path first.

    # To get count of all suspended messages
    # PS > .\GetSuspended.ps1 -action counts

    # To list all suspended messages
    # PS > .\GetSuspended.ps1 -action list

    # To save all suspended messages
    # PS> .\GetSuspended.ps1 -action save -path 'X:\[Path]'

    # To resume resumable suspended messages
    # PS> .\GetSuspended.ps1 -action resume

    # To terminate non-resumable suspended messages
    # PS> .\GetSuspended.ps1 -action terminate

# -----------------------------------------------------------------

# declare params: 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=1 or ServiceClass=4) and ServiceStatus = 4'
}

#

# save the message associated to the
# specified messaging Service Instance
#
function bts-save-message([string]$msgid, [string]$sname, $homepath)
{

    #save each message within respective folders.

    "msgid is $msgid"
    "ServiceName is $sname"
    "msg_counter is $counter"
    $msg = get-wmiobject MSBTS_MessageInstance `
    -namespace 'root\MicrosoftBizTalkServer' `
    -filter "ServiceInstanceID = '$msgid'"

    $newpath = (Join-Path $homepath $sname)
    "new path is $newpath"

    $r_code= (test-path $newpath)
    "return code is $r_code"

    if ($r_code -eq $False)
       {
       md $newpath
       "new directory created"
    }

    foreach($m in $msg)
    {
       $m.psbase.invokemethod('SaveToFile', ($newpath))
       "Message from ServiceInstanceID=$msgid saved to $newpath."
   }

}

#
# save the message associated to the
# specified messaging Service Instance
#
function bts-save-message1([string]$msgid)
{

    $msg = get-wmiobject MSBTS_MessageInstance `
    -namespace 'root\MicrosoftBizTalkServer' `
    -filter "ServiceInstanceID = '$msgid'"
    $msg.psbase.InvokeMethod('SaveToFile', ($path))
    "Message from ServiceInstanceID=$msgid saved."
}

#
# list resumable suspended instances
#
function bts-get-resumable-suspended()
{
    get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter 'ServiceStatus=4'
}

#
# list resumable suspended instances
#
function bts-get-nonresumable-suspended()
{
    get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter 'ServiceStatus=32'
}

#
# resume instance
#
function bts-resume-instance([string]$msgId)
{
    if(!($msgId -eq “”))
    {
       "Resume {0}" -f $msgId
       $msg = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter “InstanceID = '$msgId'”
       $msg.Resume() | Out-Null
    "- Done"
    }
    else
    {
       "MessageId missing"
    }
}

#
# terminate non resumable instance
#
function bts-terminate-instance([string]$msgId)
{
    if(!($msgId -eq “”))
    {
       "Terminate {0}" -f $msgId
       $msg = get-wmiobject MSBTS_ServiceInstance -namespace 'root\MicrosoftBizTalkServer' -filter “InstanceID = '$msgId'”
       $msg.Terminate() | Out-Null
       "- Done"
   }
   else
    {
       "MessageId missing"
   }
}

#
# main script
#
switch ( $action )
{
    'counts' {
       bts-get-messaging-svc-instances |
       %{ $counter++; }

       "Total: $counter"

       $counterrr = 0
       bts-get-resumable-suspended | %{ $counterrr++; }

       "Resumable: $counterrr"

       $counternr = 0
       bts-get-nonresumable-suspended | %{ $counternr++; }

       "Non resumable: $counternr"
    }

   'list' {
        bts-get-messaging-svc-instances |
       fl InstanceId, ServiceName, SuspendTime, HostName,
       ServiceStatus, ErrorId, ErrorDescription
    }
    'save'
    {

       #Set home path
       $timestamp = Get-Date -UFormat "%Y%m%d%H%M%S"
       $newpath = (Join-Path $path $timestamp)
       "Home path is $newpath"

       $r_code= (test-path $newpath)
       "return code is $r_code"

       if ($r_code -eq $False)
       {
          md $newpath
          "new directory created"
       }

        #save summary
       $wmi = get-wmiobject MSBTS_ServiceInstance `
       -namespace 'root\MicrosoftBizTalkServer' `
       -filter '(ServiceClass=1 or ServiceClass=4) and ServiceStatus = 4' | out-string

       $file = New-Item -Type File -Name "Summary.txt" -Path $newpath
       Add-Content $file -Value $wmi

       bts-get-messaging-svc-instances |
       %{ $counter++; bts-save-message $_.InstanceID $_.ServiceName $newpath }

    }
    'resume'
    {
      bts-get-resumable-suspended | %{ bts-resume-instance($_.InstanceID) }
    }
    'terminate'
    {
      bts-get-nonresumable-suspended | %{ bts-terminate-instance($_.InstanceID) }
    }
}

BizTalk 2013 Licensing – cheaper? Maybe, maybe not!

Note this is not the official Licensing document for BizTalk Server! Please consult Microsoft before making any purchase decisions.

Overview

With the BizTalk 2013 (english locale) SKUs hitting the Microsoft sites for purchase in April. It is important to note an important change Microsoft have made to the BizTalk 2013 licensing model. Up till now (i.e. BizTalk 2010), BizTalk followed a per processor model (ie a physical socket) . With BizTalk 2013, Microsoft have changed the model to be per core. Just like SQL Server.

But what does core licensing mean? How does it affect your costs? For this, one must understand the concept of a core.

As per the wiki, a core is a central processing unit within a processor. So a dual core processor would have 2 cores, a quad core would have 4 cores and so on.

The above is a dual core processor with 2 cores.

The per processor model of licensing has its own problems. One could buy a processor license for a quad core processor and still end up paying for one processor and get the processing power of 4 processors. With the new model, a license has to be purchased for every core. That is 4 licenses would be required in this particular example. Core prices are costed as the 1/4 of the processor license cost.

Lets do some cost analysis between the two model for the same spec (prices are approx):

Per Processor (quad-core): ~$40,000 x 1 = ~$40,000

Per Core (quad-core):  ~$10,000 x 4 = ~$40,000

From the above, there is not much difference in this example. However, if you ended up using 5 cores for argument sake, what do the numbers look like between the two models?

Per Processor (quad-core + single core): ~$40,000 x 2 = ~$80,000

Per Core (quad-core + single core):  ~$10,000 x 5 = ~$50,000

There you have significant cost savings for almost $30,000 with the new model!

Some Key-points

  • All the cores in the server must be licensed.
  • Licenses can be purchased in pack of two.
  • Minimum of 4 core licenses required (if your server has less than 4 cores, ex: single core and dual core machines)
  • Actual number of core licenses required may vary based on processor type and core factor.

Prices

The estimated price for a core license is approximately $10,835 for Enterprise and $2,485 for Standard.

How do you calculate the cores?

In order to calculate the cores, core-factor must be understood. A core-factor is different for different brands of processors.

Type Core-factor
Single Core 4
Dual Core 2
AMD processors (6 cores or above) 0.75
All others 1

So if you were using a 12 core AMD processor, the license cost would be calculated as follows:

AMD: 12 cores x 0.75 = 9 core licenses required.

Intel: 12 cores x 1 = 12 core licenses required.

Conclusion

From the above, it is apparent that the licensing costs entirely depend on how BizTalk Server is deployed and the type of hardware. It affects different companies in different ways.

BAMAlerts – The activation state cache could not be updated.

If you have log shipped or detached/attached the BAMAlerts databases, you will have issues starting the notification service on the BizTalk server for BAM alerts. The reason for this, when these databases are restored, the the ‘Cross-Database Ownership Chaining’ option on the BAMAlertsApplication and BAMAlertsNSMain databases is disabled and greyed out. Greyed out because it can only be enabled via a script.

cross_chaining

To enable these options, run the following command (you need to be sys-admin):

–set chaining for a database

alter database BAMAlertsApplication set DB_CHAINING ON

GO

alter database BAMAlertsNSMain set DB_CHAINING ON

GO

—-

Once done, you should be able to start the BAM alerts notification service on the BizTalk Server.

Welcome BizTalk 2013 beta

Microsoft recently released the beta release of BizTalk Server 2013. The first good news is that the initial name (BizTalk 2010 R2) has changed to BizTalk 2013, indicating it will be a major release, providing longer support to our customers!

The beta contains the following capabilities:
Integration with Windows Azure Service Bus – these are mainly out-of-the-box adapters for Windows Azure Service Bus (both messaging & relay)
Support for REST – seeing the web- & device-world move to a REST-oriented approach, it is a very good thing to see support for REST in BizTalk 2013. And this is not only for consuming, but also for exposing RESTful services!
SFTP adapter – this has been a request for years and it’s with great relief that a true SFTP adapter will be part of BizTalk 2013
ESB Toolkit – The ESB toolkit has been one of the most unclear parts of BizTalk since its inception. From guidance over toolkit and now ending up as part of the product. The configuration experience is much better, which is already good.
Dependency tracking – the administration console now shows the dependencies between artifacts
Other changes – enhanced SharePoint adapter, improvements in send ports…
Host Integration Server- that comes with the BizTalk license, also has some improvements in the following areas: DB2 integration, TI management, Support for MQ v7.5 & v7.1

Download Link:

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

What first looked like a pure platform update (aligning with SQL Server 2012, Windows Server 2012, .NET 4.5) now has changed to a big upgrade with a lot of enhancements to the product.