It took a while for the online version to appear but you can find the article, "Introduction to BizTalk Server's Features and Benefits" , here.

The Twin Cities BizTalk User Group now has a website, you can find it here:  http://www.mnbiztalk.com/

If you are a BizTalker, and live in or around the Twin Cities, and you haven't attended a session yet - I strongly encourage you to attend.  The sessions are great and the environment isn't as "stiff" as some of the other users groups out there :)

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

'Thank you' to everyone who attended the Debugging Tips and Tricks webcast that I presented today for the BizTalkRocks community.  You can find the presentation at http://www.biztalknuggets.com/presentations/BizTalk Debugging Tips and Tricks.zip

 

I recorded the webcast.  I will repost this article and include a link to the recorded webcast when it is posted.

 

If you have any questions on the presentation or the webcast please contact me through the Contact link on this blog.

 

Update (12/9/05): I think I skipped a slide yesterday. If you download the presentation, search for 'BizUnit' to find another 'Other Tools...' slide.  Sorry about that.

Update (3/26/07): Updated the link to the presentation.

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

A couple of weeks ago I was having difficulty turning on Windows Integrated security for a couple of virtual directories that were interfaces to the SOAP and HTTP adapter.  I initially had Anonymous and Integrated Windows turned on.  As soon as I turned off anonymous and left only Integrated Windows security turned on I would get prompted to enter my credentials.  After three failed attempts to login I would get the following error message: ‘HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.’

 

I assumed that I didn’t have the ACLs properly configured on the directories and files that the virtual directories managed but after reviewing their configuration everything checked out.

 

I stumbled across a reference to AuthDiag, a new tool from MS that helps you troubleshoot authentication and authorization issues with IIS 5.x and 6.0.  I installed the tool, ran the ‘Check Authentication’ test on the virtual directories and quickly discovered that my issues had something to do with the fact the identity for the application pools that my virtual directories were running in wasn’t configured properly.  Auth Diag kept giving me a failure with the message ‘Service principal name (SPN) for user xx\yy not found in Active Directory’ where xx was the domain and yy was the user name for the account I was using as the application pool identities.  (As you probably know, if you have multiple BizTalk Servers in your BizTalk Group then you must use domain accounts for you host instance credentials and I was using the same account for the application pool identities.) 

 

After a suggestion from a colleague, I switched the identities for the application pools to a local account (Network Service) and the prompt and 401 immediately went away.  Of course the requests couldn’t make it into BizTalk because the local Network Service Account didn’t have the permissions to reach the BizTalk MessageBox database.

 

Another colleague suggested using wfetch.exe, part of the IIS 6.0 Resource Kit to help debug my issue.  I ran wfetch.exe using NTLM (for the ‘Auth’ value in the ‘Authentication’ group box) and could access the virtual directories without problems.  However, when using either Kerberos or Negotiate I saw the following error message in the response from the IIS: ‘0x80090322 (The target principal name is incorrect.): Unable to InitializeSecurityContext’.  This article describes the differences between these three options although it describes these in the context of the IIS authentication and not wfectch.exe

 

I was stumped until I found the Configuration Application Pool Identity in the IIS 6.0 documentation.  According to that page, there are issues with using Kerberos (which may be used when you use Integrated Windows Security.)  The solution to my problem was that I needed to run the setspn.exe tool in order to set a Service Principal Name (SPN) on the account configured as the Identity for the application pools.  We ran setspn.exe using the machine name and the machine’s fully qualified domain name, and the issue immediately went away:

 

setspn -A HTTP/servername domain\account

setspn -A HTTP/servername.fullyqualifieddomainname domain\account

 

You can find the setspn.exe tool on the Windows 2003 CD-ROM or .ISO at \support\tools\suptools.msi

 

One thing to note about setspn.exe is that you must be a domain administrator, of the domain that the account is in, that you use as a parameter to setnspn.exe (which is also the account you are using for the application pool identity.  There is a note here (click on the ‘Troubleshooting Setspn’ link) that says the permission necessary for running the setspn.exe can be delegated.

 

In summary, you must execute setspn.exe if you are using domain accounts for your application pool identities if you are using Integrated Windows Security.

This post disappeared from a previous blog of mine so I'm reposting it.

---

I've installed BizTalk 2004 on a developer workstation several times at this point.  For a developer workstation I recommend the following:

1) If you do 'regular' ASP.NET development on your workstation and you will continue to do so after installing/configuring BizTalk then when you are configuring Windows SharePoint Services (WSS) do not configure it to use your default website.  Create a second website in IIS and point to this site during WSS configuration (and later during BizTalk configuration point to this site instead of your default web site for the BAS site location.)  If you don't do this you will have to put your ASP.NET applications on a second website that doesn't run on port 80 or you will have to configure WSS to not 'apply' to each Virtual Directory that you want to use for ASP.NET applications.

2) I have never succesfully been able to create the WSS configuration db from the WSS configuration wizard.  I always get an access denied error when it tries to create the configuration database, complaining about NT Authority\Network Service not having appropriate access to the database (or something like that.)  Instead, I create the WSS configuration database prior to configuring WSS using the Using the Command Line to Create or Connect to a Configuration Database section of the Administrator's Guide for SharePoint Services.  This section describes how you can use the following command to create the config database:

stsadm -o setconfigdb -ds -dn

You can then point to the database you created with stsadm during the WSS configuration.

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

I've been doing some research on custom adapter development and one of the issues that came up was figuring out how to do the schema generation.  BizTalk Server 2004 includes a wizard that will generate schemas from Xml instance documents.  I decided to figure out how it worked - and if it could be reused.

 

It is possible to reuse this functionality.  Here's how you do it:

 

  1. Create a console project.
  1. Reference the Microsoft.BizTalk.WFXToXSDGenerator.dll and XSDInfer.dll assemblies in the [installDir]\Microsoft BizTalk Server 2004\SDK\Utilities\Schema Generator directory. 
  1. Reference the Microsoft.BizTalk.SchemaEditor.Extensibility.dll assembly in the [installDir]\Program Files\Microsoft BizTalk Server 2004\Developer Tools directory.
  1. Pull in the Microsoft.BizTalk.WfxToXSDGenerator namespace.
  1. Add the following code to your Main method:

 

WfxToXSDGenerator gen = new WfxToXSDGenerator();

 

gen.GenerateSchema(args[0], args[1]);

 

object[] warnings = gen.Warnings();

object[] errors = gen.Errors();

object[] schemas = gen.ReferencedSchemas();

 

if(warnings.Length != 0)

{

Console.WriteLine("Warnings were found:");

 

          for(int i = 0; i < warnings.Length; i++)

          {

        Console.WriteLine(warnings[i].ToString());

          }

 

          Console.ReadLine();

          return;

}

 

if(errors.Length != 0)

{

Console.WriteLine("Errors were found:");

 

          for(int i = 0; i < warnings.Length; i++)

          {

        Console.WriteLine(errors[i].ToString());

          }

 

          Console.ReadLine();

          return;

}

 

if(schemas.Length !=0)

{

Console.WriteLine("The following schemas were generated:");

 

          for(int i = 0; i < schemas.Length; i++)

          {

        Console.WriteLine(schemas[i].ToString());

          }

 

          Console.ReadLine();

          return;

}

 

Notes:

  • The first argument to the GenerateSchema method is the location of the Xml instance document.  The second argument is the output directory for the generated schemas.
  • A Warning and Errors array is present; oddly you access these through methods, not properties.  I didn't run into any errors or warnings so I didn't investigate their Types; my assumption is that they are string but it would be easy for you to figure this out if you run into issues.
  • GenerateSchema() doesn't overwrite schemas you already created with it; it adds a n (a number starting with 1) to the end of the filename (i.e. sample1.xml)
  • There does appear to be another MS Xsd inference assembly out there (http://www.fawcette.com/xmlmag/2002_11/online/xml_rjennings_11_11_02/); perhaps the assembly is later version of this assembly.Should be fairly robust given this is what the Wizard uses (inferred from the directories.)
  • I did not investigate the DTD version of the generator.

 

Why would you use reuse this library?  A couple of thoughts come to mind: when automating batch schema generation and when writing custom application adapters.  Obviously, there are other resources available on the web (and within VS.NET) that can generate schemas from Xml instance documents but I assume that this library has been put through a rigorous QA process (although it is a sample according to this post http://groups-beta.google.com/group/microsoft.public.biztalk.sdk/browse_thread/thread/913c7fa57fc127a/2ac3418b674f5da8?q=ISchemaGenerator#2ac3418b674f5da8 [I wonder why it is in the utilities directory if it is a sample?]) given its usage in BizTalk Server 2004.

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

Are you read to take your BizTalk Server 2004 application to production?

 

Integration applications are usually very complex; they have a lot of moving pieces, they use many different technologies and they are often built to automate processes that are not understand nearly as well as the business units involved think they are understood.  In addition to the technical problems related to integration applications, integration problems have a corresponding set of issues centered around communication difficulties.  Often these communication difficulties arise because the different teams involved in the project do not understand ant technologies other than their own, because people of various technical levels are involved in project and because project teams do not reside at the same physical location.

 

Because of these complexities it is easy to overlook items that should be handled prior to your BizTalk Server 2004 application going live.  The article contains suggestions for items you should resolve prior to going live.

 

Deployment

  • Is your deployment automated?  Fully automated?
  • Have you defined your rollback procedures?

 

Application Architecture Review

  • Have you covered all of your error handling scenarios from you requirements?
  • Will HAT provide all of the necessary debugging, process analysis and replay requirements for your application?  If not you may need to
  • Database recovery, backups, failover, etc.
  • Logging - where, how, when?
  • How are you going to monitor you application and environment?  What happens after hours?  Have you considered Microsoft Operations Manager?
  • How are you going to implement notification?  Who gets notified?  When?  Will you filter so that you don't send out notifications for each and every BizTalk related event log entry?
  • Will you have enough information to debug your problems (they will occur!)?
  • Can you really guarantee delivery?  Did you design your orchestrations correctly?
  • Have you reviewed the Performance and High-availability whitepapers?

 

Hardware Architecture Review

  • Are your environments the same from Development to Production?
  • If necessary, have you really eliminated single-points of failure? What about the resources BizTalk will depend on such as MQSeries server, databases, etc.  You are as weak as you weakest point.
  • Can you really meet you availability requirements?
  • If necessary, do you have an environment that you can perform load and performance testing in?  Do you have access to it?  You will need access to it so that you can change tuning settings.

 

Operations Staff

  • Do you know how to work with HAT?
  • Will you have access to HAT in you production environment?  If not, how will you work with your operations staff during issues?
  • Have you trained your operations staff on HAT?
  • Does your operations staff know how to use your deployment tool?
  • Does your operations staff know how to use BizTalk Administration?
  • Have you planned your situation handling procedures and documented them?
  • Does operations understand all of your application scenarios?
  • Does operations understand the service-level agreement for you application?  For your platform?

 

Testing

  • Have you tested failover scenarios?
  • Can you really run your business scenarios in your pre-production environment?  If not, be prepared for issues in production soon after you deploy there.
  • Are your environments the same from Development to Production?
  • For applications that will be under heavy load, when you PoC'ed did you test the PoC under a full load?  You might be surprised at what happens if you only tested with a percentage of your full load and extrapolated.
  • For applications that will be under heavy load, have you tested all of the adapters separately?  They behave very differently under load and have different tuning settings.
  • Have you tested all of you unhappy paths?
  • Does everyone know what end-to-end testing means?  Are you sure?
  • Do you have testing schedule defined?  This can be very difficult to plan given that integration applications often have many systems and departments involved.

 

Business

  • Have you reminded the business units about the new process changes?
  • Have you defined the communication paths between the involved business unit/parties when problems occur?  This is also something that your operations staff will have to know about.
  • Does the business know how/when they will be notified of issues; this includes automated notifications and SLA requirements for how the operations staff will notify customers about issue resolution?

 

This list of items is not exhaustive and there are likely many other things that you should consider for your particular situation prior to taking your BizTalk Server 2004 application to production; however, I have provided a sample of items that you may have not thought of and that will hopefully provide some motivation to discover other items for you particular situation.

 

If you have other suggestions for this list, let me know.

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

A couple of weeks ago I wrote a short article about an ‘easy’ method of determining the correct BTSNTSvc.exe process to attach to in VS.NET in order to debug orchestration utility components.  Scott Colestock described a better way to determine this here.

 

I liked his method much better than mine but I didn’t want to have Perfmon open whenever I needed to find the correct process id.  I took his suggestion one step further and created a simple console application that writes out the process ids of all started, in-process host instances.  Here are the steps to create (using C#) and use this simple application:

 

  1. Create a new .NET console application.
  2. Add a reference to System.Management.dll
  3. In the class that contains your main() method add using statements for:
    1. System.Diagnostics
    2. System.Management
  4. Add the following code to the main() method:

 

                  //Enumerate all HostInstances of "InProcess" type

                  try

                  {

                        //Create EnumerationOptions

                        EnumerationOptions enumOptions = new EnumerationOptions();

                        enumOptions.ReturnImmediately = false;

 

                        //Search for all HostInstances of 'InProcess' type in the Biztalk namespace scope

                        ManagementObjectSearcher searchObject = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer","Select * from MSBTS_HostInstance where HostType=1 and ServiceState=4",enumOptions);

 

                        //Enumerate through the ManagementObjects and write out the Host Instance Process Ids.

                        foreach(ManagementObject inst in searchObject.Get())

                        {

                              string hostInstanceName = (string)inst["HostName"];

                              PerformanceCounter pc = new PerformanceCounter("BizTalk:Messaging", "ID Process", true);

                              pc.InstanceName = hostInstanceName;

                              float instanceId = pc.NextValue();

 

                              Console.WriteLine(hostInstanceName + ": " + instanceId);

                        }

                  }

                  catch(Exception ex)

                  {

                        Console.WriteLine(ex);

               }

  1. Compile the project.
  2. Add a new External Tool to VS.NET
    1. Open VS.NET, go to Tools, External Tools.
    2. Click Add
    3. Give this tool a Title, I called it ‘BTSHostInstanceProcessIds’
    4. For the Command, browse to the .exe that you just compiled, above.
    5. Check the Use Output Window checkbox.

 

That’s it.  Now when you need to know the process ids for your in-process host instances you can use this tool from the VS.NET Tools window.  Execute it just prior to attaching the debugger.  It will write out the host instance name (actually it is the host instance’s host name) and their process ids to the VS.NET Output window like this:

 

BizTalkServerApplication: 2856

TrackingHost: 4540

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

One may get the impression, based on the example configuration listing for 'AppDomain configuration' in the BTS docs (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sdk/htm/ebiz_prog_orch_jzex.asp), that the Orchestration Engine's default values for SecondsIdleBeforeShutdown and SecondsEmptyBeforeShutdown are 1200 and 1800, respectively.   The example configurations are so plagued with errors that I investigated a bit further.

In the Microsoft.XLANGs.BizTalk.CrossProcess.AppDomains constructor (in the Microsoft.XLANGs.BizTalk.CrossProcess assembly),
the default values are set to the reverse:

SecondsIdleBeforeShutdown = 1800 (30 minutes)
SecondsEmptyBeforeShutdown =  1200 (20 minutes)

Obviously these values could be reset to something other than their default values by code that executed after the constructor but it does appear that the default values are reversed in relation to the example's configuration.

In case you are not familiar with the settings here is a snip from the referenced page in the BizTalk docs:

"In this section the user may specify default configuration for any app domain created that does not have a named configuration associated with it (see AppDomainSpecs below) SecondsEmptyBeforeShutdown is the number of seconds that an app domain is empty (that is, it does not contain any orchestrations) before being unloaded. Specify -1 to signal that an app domain should never unload, even when empty. Similarly, SecondsIdleBeforeShutdown is the number of seconds that an app domain is idle (that is, it contains only dehydratable orchestrations) before being unloaded. Specify -1 to signal that an app domain should never unload when idle but not empty. When an idle but non-empty domain is shut down, all of the contained instances are dehydrated first."

I encourage you to review all of the Orchestration Engine settings on the referenced page; many of them are very useful.

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

When using the xpath() function in the orchestration designer you may need to obtain the value from a single node (I'm distinguishing between trying to obtain the node vs. the node's value.)  If you are attempting to do this, please don't forget to wrap your xpath statement with the xpath string function, for instance:

 

myStringValue = xpath(myMessage, "string(/*[local-name()='MyElement' and namespace-uri()='']/@*[local-name()='MyAttribute' and namespace-uri()=''])");

 

If you forget to do this your variable (in this case myStringValue) will have a value of null and depending on your usage of that variable later on in your orchestration you may end up with an exception.

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

I've been working with a third-party database adapter that returns encoded Xml in some cases.  BizTalk handles the decoding just fine but when I have problems with the adapter it can be problematic to examine the encoded documents.  After a few days of dealing with this I put together a couple of VS.NET macros for encoding/decoding Xml which I'm sure people can find other uses for.

 

Here's how you can create these macros:

 

  1. Open VS.NET.
  1. View the Macro Explorer.
  1. Copy and paste the code snips, below, into appropriately named macro module (I created a new Macro Module and named it XmlHelpers.)
  1. Make sure you add a reference to System.Web in the macro editor for the macro module you just pasted the code snips into.
  1. Add an Imports statement for System.Web
  1. Save the macro.
  1. Select an Xml fragment in the editor that you would like to encode or decode.
  1. Double-click the XmlEncode or XmlDecode macro in the Macro Explorer.
  1. Note that it is actually using the System.Web.HttpUtility.HtmlEncode/HtmlDecode functions.

 

Here are the snips:

 

Sub XmlDecode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text

 

theTextSelection.Delete()

theTextSelection.Insert(HttpUtility.HtmlDecode(actualText))

End Sub

Sub XmlEncode()

Dim theTextSelection As TextSelection = DTE.ActiveDocument.Selection

Dim actualText As String = theTextSelection.Text

 

theTextSelection.Delete()

theTextSelection.Insert(HttpUtility.HtmlEncode(actualText))

End Sub

 

This post disappeared from a previous blog of mine so I'm reposting it.

---

 

Earlier this year Microsoft released the Enterprise Library v1.0.  The Enterprise Library consists of several Application Blocks that can be used to provide software infrastructure for enterprise application development.  According to the Enterprise Library documentation, the “Application blocks are reusable software components designed to assist developers with common enterprise development challenges.”  One of these Application Blocks, the Logging and Instrumentation Application Block, is the part of the focus of this article.

 

The purpose of this article is to explain how to set up the Logging and Instrumentation Application Block for BizTalk Server 2004 and BizTalk Server 2004 applications and to examine a simple sample application show its usage in a BizTalk Server 2004 application.  Detailed discussion on when and how to log are not covered in this article.

Why Logging is Important in BizTalk Server 2004 Applications

Although BizTalk Server 2004 supports tracking and the viewing of tracking data in HAT there are very good reasons for using ‘traditional’ logging and methods in BizTalk Server 2004 applications:

·         BizTalk Server 2004 tracking has a performance degradation cost associated with it; in some cases the performance degradation cost can be substantial.

·         You can gain explicit control as to when logging messages are sent using logging filters.

·         You can gain explicit control as to how the logging messages are sent (Event Log, database, file, email, etc.)

·         You can categorize logging messages (debug, exception, trace, etc.)

·         You gain control of the format of the logging messages.

·         You can create your own events/notifications that could be subscribed to with other software components.

·         If you do not have access to HAT in your production environment you can still get valuable data ‘sent’ to your development team.

 

Scott Colestock wrote an article on using log4net in BizTalk Server 2004 here.  His article also contains some additional reasons why ‘traditional’ logging is still important in BizTalk Server 2004 applications.

Logging and Instrumentation Application Block Core Concepts

From the Logging and Instrumentation Application Block Documentation:

“The Enterprise Library Logging and Instrumentation Application Block version 1.0, lets developers incorporate standard logging and instrumentation functionality in their applications. Applications can use the Logging and Instrumentation Block to log events to a variety of locations:

·         The event log

·         E-mail messages

·         A database

·         A message queue

·         A file WMI

The Logging and Instrumentation Application Block helps with application development in a number of ways:

·         It helps maintain consistent logging and instrumentation practices, both within an application and across the enterprise. It eases the learning curve for developers by using a consistent architectural model.

·         It provides implementations that you can use to solve common application logging and instrumentation problems.

·         It is extensible, supporting custom implementations of formatters and event sinks.”

The Logging and Instrumentation Application Block contains several extension points including creating new categories for logging, creating new event sinks, and new context providers.

Prerequisites and Installation

·         Obtain the Enterprise Library from http://www.microsoft.com/downloads/details.aspx?FamilyID=0325B97A-9534-4349-8038-D56B38EC394C&displaylang=en

·         Install the Enterprise Library, following the instructions included with it; there are patches for the Enterprise Library available at http://www.gotdotnet.com/workspaces/workspace.aspx?id=295a464a-6072-4e25-94e2-91be63527327

·         Read the documentation for the Configuration and Logging and Instrumentation Application Blocks

o        Go to Start, All Programs, Microsoft patterns and practices, Enterprise Library, Enterprise Library Documentation.

·         Other suggested reading topics on the Logging and Instrumentation Application Block:

o        http://blog.hishambaz.com/archive/2005/01/29/194.aspx

o        http://blog.hishambaz.com/archive/2005/01/30/202.aspx

o        http://blog.hishambaz.com/archive/2005/02/05/253.aspx

o        http://www.codeproject.com/dotnet/GetLoggingWithEntLib.asp

Setting up the Logging and Instrumentation Application Block for BizTalk Server 2004

These instructions are for setting up the Enterprise Library for use within BizTalk Server 2004 applications, on a machine with Visual Studio.NET 2003 installed.

 

·         So that the Logging and Instrumentation Application Block can be used from BizTalk Server 2004, you must associate the non-.Design projects (projects names ending in .Design) with a .snk so that they can be deployed to the GAC; I signed all non-.Design projects (all project’s that do not have names ending in ‘.Design’) to keep things simple.

o        Open the Enterprise Library solution

§         Go to Start, All Programs, Microsoft patterns and practices, Enterprise Library, Application Blocks for .NET, Enterprise Library Solution

o        Associate the non-.Design projects with the C:\POC_BTS_LoggingAppBlock\EnterpriseLibrary.snk; if you do not sign it with this .snk, you will need to update the three of the four .config files associated with the sample before it will work correctly.  You will need to update the PublicKeyToken references so that their value is set to the public key token associated with your .snk.

o        Rebuild the Enterprise Library.

o        Move the assemblies to the Enterprise Library’s bin directory.

o        If you have already installed the services you need to uninstall the services.

o        Now Install Services.

o        Install the assemblies into the GAC.

o        If you are performing these actions on a workstation with VS.NET installed you can use the shortcuts at Start, All Programs, Microsoft patterns and practices, Enterprise Library to perform the last five steps.

o        Note that out-of-the-box, the InstallServices.bat, that is called from the Install Services command, requires Visual Studio.NET 2003 to be installed on the machine that it executes on; in order to Install Services on a server without Visual Studio.NET 2003 reference these posts:

§         http://blogs.msdn.com/scottdensmore/archive/2005/03/17/397950.aspx

§         http://martijnh.blogspot.com/2005/03/microsoft-enterprise-library-custom.html

o        Note, you should not use the EnterpriseLibrary.snk for your actual implementations; it is only provided to keep the sample’s setup as simple as possible.

·         On Windows 2003, add the BizTalk service accounts, for the host instances that will host orchestrations using the Logging and Instrumentation Application Block, to the local ‘Performance Monitors Users’ group

 

Setting up BizTalk Server 2004 Application to use the Logging and Instrumentation Application Block

The Enterprise Library requires a ‘root’ configuration file.  The ‘root’ configuration file references other files where the Enterprise Library’s configuration data is stored.  This means that for ‘normal’ .NET applications the ‘root’ configuration file will either be the app.config or web.config.  By default, the BizTalk Server 2004, the ‘root’ .config file is [InstallDrive]\Program Files\Microsoft BizTalk Server 2004\BTSNTSvc.exe.config.  There are other options with BizTalk Server 2004; you can set up your own ‘default’ .config file for all AppDomains or you can use BizTalk’s ability to assign assemblies to Application Domains and associate the App Domains with a specific .config file.  Both of these options are accomplished my modifying the BTSNTSvc.exe.config file.

BTSNTSvc.exe.config

If you use this file as your ‘root’ .config file all of your BizTalk Server 2004 applications will utilize the same instance of your Logging and Instrumentation Application Block’s configuration.  Restated this means all of your BizTalk Server 2004 applications will be subject to a global configuration (to BizTalk) for the Logging and Instrumentation Application Block.  This may or may not be appropriate for you situation.  The sample application does not use this file for its ‘root’ configuration file.

AppDomain Assignment

Another option in BizTalk Server 2004 is to use its App Domain assignment feature.  You can assign BizTalk assemblies to a default application domain or to specific Application Domains using ‘Exact Assignment’ or ‘Pattern Assignment’; this means using the full name of the assembly or regular expressions, respectively.  You can create a default specification for App Domains using the DefaultSpec element.  You can create custom App Domains, and assembly assignments for them, using the AppDomainSpec element.

 

App Domain assignment may or may not be appropriate for you situation but it is the mechanism used in the sample for setting a ‘root’ configuration file for the Logging and Instrumentation Application Block.

 

This feature is ‘documented’ in the SDK at http://www.msdn.microsoft.com/library/en-us/sdk/htm/ebiz_prog_orch_jzex.asp. There is also a blog entry by Todd Uhl explaining this feature.

 

Note:

·         Utility assemblies, call from orchestrations will be loaded into the same App Domain as the orchestration that uses it.

  • The account associated with the host instance (that will use the Logging and Instrumentation Application Block) is running under will need to have access to the ‘root’ .config file and the other .config files created by the Enterprise Library Configuration application.

 

The generic steps to set up the Logging and Instrumentation Application Block in a BizTalk Server 2004 Application when you are using AppDomain assignment are:

·         Reference the Microsoft.Practices.EnterpriseLibrary.Logging .dll (assembly) or project.

·         Use the Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write() method to write logging messages in orchestration assembly shapes and utility components.

·         Update the BTSNTSvc.config (after backing it up) file so that the orchestration assembly is assigned to an AppDomain:

 

<AppDomainSpecs>

       <AppDomainSpec Name=”POC_BTS_LoggingAppBlock_BizTalk” SecondsIdleBeforeShutdown=”-1” SecondsEmptyBeforeShutdown=”12000”>

              <BaseSetup>

                                                       <ConfigurationFile>C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock.config</ConfigurationFile>

              </BaseSetup>

       </AppDomainSpec>

</AppDomainSpecs>

<!

The PatternAssignmentRules and ExactAssignmentRules control assignment of assemblies to app domains.

                   

When a message arrives, the name of its corresponding orchestration’s assembly is determined. Then, the assembly is assigned an app domain name. The rules guide this assignment. Exact rules are consulted first, in their order of definition, and then the pattern rules. The first match is used.

                   

If no match is found, the assembly will be assigned to an ad-hoc domain. The configuration and number of assemblies per ad-hoc domain is controlled by the AssembliesPerDomain attribute and the DefaultSpec section.

à

<ExactAssignmentRules>

<!

An exact assembly rule specifies a strong assembly name and an app domain name. If the strong assembly name equals the rule’s assembly name, it is assigned to the corresponding app domain.

à

<ExactAssignmentRule AssemblyName=”POC_BTS_LoggingAppBlock_BizTalk, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b65652986d7b9da4”

                                         AppDomainName=”POC_BTS_LoggingAppBlock_BizTalk” />

</ExactAssignmentRules>

·         Store your ‘root’ configuration file, and the other .config files that the Enterprise Library Configuration application creates, in the location specified in the appropriate AppDomainSpecs/AppDomainSpec/BaseSetup/ConfigurationFile.

Sample BizTalk Server 2004 Application using the Logging and Instrumentation Application Block

A sample application utilizing the Logging and Instrumentation Application Block can be downloaded from the GotDotNet User Samples, here.  If you have problems downloading the sample from GotDotNet, reference the ‘Feedback’ section of this article for information on contacting me; I will be happy to send it to you.

 

The sample is a very simple sample application that uses the Logging and Instrumentation Application Block from an expression shape, in an orchestration, and from a utility component called from the same orchestration.  An atomic scope is used the orchestration to guarantee that at least one persistence point is reached prior to the last call to Logger.Write(); this gave me an indication as to how the Logging and Instrumentation Application Block would act in a ‘normal’ long-running orchestration scenario where the orchestration was persisted.  The sample application uses the App Domain assignment method for associating an orchestration assembly with a ‘root’ configuration file.

 

This logging configuration has four categories:

·         Default – which is the default category with a new Logging and Instrumentation Application Block configuration; it is associated with an Event Log Sink.  This category is not used in the sample.

·         Trace – another default associated with a Flat File Sink that writes to trace.log.  This category is only used if the Logging and Instrumentation Application Block’s tracing is turned on.  It is not used in this sample.

·         INFO – a custom category for the sample; it is associated with a Flat File Sink named INFO Flat File Sink that writes to C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock_BizTalk\info.log

·         DEBUG – another custom category for this sample that is associated with an Event Log Sink

 

There are four .config files associated with this sample:

·         BTSNTSvc.exe.config – contains the App Domain assignment settings for the sample (and other default settings that come with original file installed with BizTalk Server 2004.)

·         POC_BTS_LoggingAppBlock_BizTalk.dll.config – contains references to two files used by the Logging and Instrumentation Application Block.

·         loggingConfiguration.config – used by the Logging and Instrumentation Application Block.

·         loggingDistributorConfiguration.config – used by the Logging and Instrumentation Application Block.

Setting up the Sample Application

After the Logging and Instrumentation Application Block is set up for usage in a BizTalk Server 2004 application additional setup steps must be completed for each BizTalk Server 2004 application that uses it.  For the sample application, these steps are:

·         Perform all of the steps in the ‘Setting up the Logging and Instrumentation Application Block for BizTalk Server 2004’ section of this article.

·         Unzip the POC_BTS_LoggingAppBlock.zip file to C:\

·         Backup your C:\Program Files\Microsoft BizTalk Server 2004\ BTSNTSvc.exe.config

·         Replace the C:\Program Files\Microsoft BizTalk Server 2004\ BTSNTSvc.exe.config file with the version located at C:\POC_BTS_LoggingAppBlock

·         Open the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock.sln

·         Re-reference the Logging and Instrumentation Application Block, if necessary.  Reference the assembly if you are not interested in stepping through its code, otherwise reference its project.  If you reference the project, you will also need to reference the Enterprise Library’s Common and Configuration projects.

·         Build the POC_BTS_LoggingAppBlock.sln.

·         Deploy the C:\POC_BTS_LoggingAppBlock_BizTalk assembly to BizTalk; the C:\POC_BTS_LoggingAppBlock_Utilities assembly should be installed into the GAC using a post-build event.

·         Import the POC_BTS_LoggingAppBlock bindings using the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock.xml file and the BizTalk Deployment Wizard.

·         Make sure that the host instance that will access the configuration files has write access to C:\POC_BTS_LoggingAppBlock; it needs write access because in this sample the Logging and Instrumentation Application Block writes to .log files in this directory and because a file receive location is used in the sample.

·         Start the POC_BTS_LoggingAppBlock_BizTalk.LoggingOrchestration using BizTalk Explorer or BizTalk Administration.

·         Test the solution by copying and pasting the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock_BizTalk\ InstanceDoc_LoggingSchema.xml file into the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock_BizTalk\Inbound directory.

·         Note, if you did not use the C:\POC_BTS_LoggingAppBlock\EnterpriseLibrary.snk to sign the Enterprise Library assemblies you will need to update the three .config files in the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock_BizTalk directory so that each PublicKeyToken=7f82718233b41429 is updated to use the token associated with your .snk.

·         Note, the two sample projects POC_BTS_LoggingAppBlock_BizTalk and POC_BTS_LoggingAppBlock_Utilities will be signed with the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock.snk.  If you use a different .snk, you will need to update the included BTSNTSvc.exe.config so that the App Domain assignment settings reference the PublicKeyToken associated with your .snk.

 

If the test is successful you will see two entries in the Application event log from the Enterprise Library Logging event source and two entries in the C:\POC_BTS_LoggingAppBlock\POC_BTS_LoggingAppBlock_BizTalk\info.log file.

 

If the test does not appear to be successful, examine the Application Event Log for errors an Enterprise Library [VariousNamesHere] event source.  You can also step through its code by setting a breakpoint in its source code and attached the VS.NET debugger.  You will need to reference the Logging and Instrumentation Application Block, the Configuration Application Block and the Enterprise Libarary’s Common project if you are going to step through the Logging and Instrumentation Application Block’s code.

Issues Observed During Research

Application Event Log Entries

·         “Failed to fire the WMI event 'LoggingLogWrittenEvent'.  Exception: System.Exception: This schema for this assembly has not been registered with WMI.”

o        This appeared to be related to not running Install Services on the signed version of the assemblies; to fix this:

      • Uninstall the Enterprise Library assemblies from the GAC.
      • Uninstall Services
      • Rebuild the Enterprise Library
      • Move the assemblies to the Enterprise Library bin directory
      • Install the Enterprise Library assemblies into the GAC
      • Install Services

 

·         “Failed to create instances of performance counter 'Client: # of Logs Written/Sec' - Couldn't get process information from remote machine.”

    • I had to add the BizTalk service account, for the host instance that was hosting the orchestration, to the local ‘Performance Monitors Users’ group

 

·         “Failed to create instances of performance counter 'Distributor: # of Logs Distributed/Sec' - Couldn't get process information from remote machine.” Event log entry

o        I had to add the BizTalk service account, for the host instance that was hosting the orchestration, to the local ‘Performance Monitors Users’ group

 

·         “Could not create Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationManagerSectionHandler, Microsoft.Practices.EnterpriseLibrary.Configuration, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.”

o        I did not build the Enterprise Library Configuration application against the signed version of the Application Block’s assemblies so it did not use a key token when creating new configuration files; once I built the Enterprise Library Configuration against the signed assemblies, the new Enterprise Library Configuration assembly needed to be moved to the Enterprise Library’s bin directory.

 

Other

  • On multiple occasions I was unable to debug the GAC’ed version of the Enterprise Library assemblies
    • I never determined a definitive reason for this (obviously things got ‘out-of-sync’) but these steps always cleared it up:
      • Uninstall the Enterprise Library assemblies from the GAC.
      • Uninstall Services
      • Rebuild the Enterprise Library
      • Move the assemblies to the Enterprise Library bin directory
      • Install the Enterprise Library assemblies into the GAC
      • Install Services

Potential Constraints/Concerns of Using the Logging and Instrumentation Application Block in BizTalk Server 2004

  • Inability to use the Tracer() class in orchestration because it is not [Serializable] and it uses some thread-relative storage mechanism internally:
    • More investigation is necessary
    • In any case, XLANG/s does not support C# ‘using’ statement (the ‘using’ statement related to Dispose().)
    • However, BAM supports this type of ‘tracing’.
  • Inability to use the out-of-the-box classes that implement IExtraInformationProvider for context information because they are not Serializable. 
    • However, custom implementations of IExtraInformationProvider can be created.
  • Start up time takes several seconds the first time the Logging and Instrumentation Application Block is accessed.
    • Consider using a command message and/or an orchestration that calls the Logging and Instrumentation Application Block prior to its usage in ‘real’ applications, if this is a problem for you.
  • Time lag between changing logging configuration and seeing the configuration changes reflected in the output takes a few seconds.
  • No performance or load testing was performed during the POC work on using the Logging and Instrumentation Application Block with BizTalk Server 2004.
  • There may be issues associated with Application Domain assignment in BizTalk Server 2004; this does not appear to be a well-known feature.
  • Although configuration can be partitioned by assembly using BizTalk’s App Domain assignment feature, this may not be granular enough for you needs, if you have many orchestrations in a single assembly.

Other Constraints/Concerns

  • None of the other Enterprise Library Application Blocks were used in my research; however the Logging and Instrumentation Application Block does use the Configuration Application Block to retrieve its configuration data.
  • I have not dealt with a server deployment of the Enterprise Library and this article only briefly mentions how a server deployment is different from a deployment where Visual Studio.NET 2003 is installed.
  • I have only tested this sample on one Windows Server 2003 system.  I expect there to be minor issues with the sample, this document and using the Logging and Instrumentation Application Block from BizTalk Server 2004. 

 

Next Steps

I will post updates, issues and tips on the Logging and Instrumentation Application Block in BizTalk Server 2004 as I work with it more.  These will be posted on my blog (see below) as they become available.

Feedback

I am very interested in hearing about your experiences with using the Logging and Instrumentation Application Block in BizTalk Server 2004. 

 

If you have any issues with the sample or using the Logging and Instrumentation Application Block in BizTalk Server 2004, please let me know by contacting me through this blog.

News



Archives

Post Categories

Syndication: