Sorting, Grouping, and Debatching in Pure Messaging

Debatching can be done several different ways in BizTalk 2004. With a few message box hops, debatching can be done with a few maps and an envelope schema in pure messaging. This sample shows a map for Sorting, a map for Grouping, and the Envelope for debatching.

This sample will work in BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2006/04/03/how-to-use-biztalk-messaging-for-grouping_2c00_-sorting_2c00_-and-debatching.aspx

Working With Start Orchestration Shapes, Self Correlated Ports, and Configured Port Parameters

These three topics could be entire blog posts on there own.  In this case, I’ll briefly cover all three and show how to use them all together.



Start Orchestration – This shape give you the ability to asynchronously start a new Orchestration.  You can pass in all types of parameters but you can not return parameters like the Call Orchestration Shape. 



Passing Configured Port Parameters – This is an input parameter type for Call and Start Orchestrations.  This can be used to pass in already configured ports to use to send messages back into the original Orchestration. 



Direct Binding using Self Correlation – When passing Self Correlation ports to a Started Orchestration a unique token is placed in BTS.PartnerService.  This is used for the return subscription.  I have not worked with Self Correlation Ports in any other scenario although they can be used on there own without a Start or Called Orchestration.



Solution Overview:  A single message is received into a Master Orchestration (Master).  This single message is then used to Start two different Orchestrations (SharedLogicA and SharedLogicB).  Inside these two Orchestrations, the message is “processed” (i.e. mapped and a 5 to 15 second delay is used to simulate processing).  The resulting mapped messages are returned to the Master Orchestration.  A single result message is sent out.



Download: Passing Configured Port Parameters Sample



The master Orchestration looks something like this:





How does this differ from Direct Binding Using Partner Ports? 


It is very similar except that you do not use the Start Orchestration shape (thus can not pass parameters, multiple messages, and so on).  Using Partner Ports, if you wanted a message back you would need to create a Correction Set and work out all those complexities.  There is some other under the cover differences between the two but that is for another post.



How to set this up on your own:


Step 1: Create the Master Orchestration with a Receive Port and a SharedLogic Orchestration.  Set up all required input and output messages.  Set up the Send Shape inside the SharedLogic Orchestation to send back the correct message.



Step 2: Inside the Master Orchestration add the Receive Shape and set it up to receive the response message from the SharedLogic Orchestration.  Select the Red ! to configure the Operation for the Receive Shape.  Give the Port a name (Port_A), create a new port type (PortType_A), select Directing Binding – Self Correlation.





Step 3: Inside the SharedLogic Orchestration add the parameters that will be passed in by from the Master.  In this case, an input message (InputA) and a configured port parameter (Port_1).  For the port type, select the type create above (PortType_A), for Port Binding select “I’ll always be sending messages on this port”.  Connect your Send Shape to your new Port. 









Step 4: Lastly, inside your Master Orchestration add a Start Orchestration Shape.  Select your Sharedlogic Orchestration.  Set your two input parameters if needed.







Note that you can send and receive messages on the same port type when using the Start Orchestration Shape.  If you tried this same approach with the Call Orchestration shape you would get a build error.  Read more about this on Charles Young awesome article on this topic.

Long Term Facts In the Business Rules Engine

This sample shows how to call the BizTalk Business Rules from .net code. This sample passes in .net objects (using Helper .Net Components in the Orchestration) as facts and gets updated values returned from the rules engine. It also uses a long term fact creator defined on the Policy to cache long term facts. Make sure you read the ReadMe.txt for set up information.

This should work for both BizTalk 2004 and BizTalk 2006.

Get more information from the original blog post on this topic: http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2006/01/27/using-.net-components-and-long-term-facts-with-biztalk-rules.aspx

Using .Net Components and Long Term Facts With BizTalk Rules

Recently I have been working a lot with the BizTalk Rules Engine (BRE) that comes along with Biztalk Server 2004. 



Rather than the more common approach of using the BRE inside a BizTalk Orchestration passing in XML messages, I have been working with the rules engine in a pure .net scenario passing in .net objects as facts and working with a long term fact creator.



This approach uses the available API to call the BRE inside .net and passes in an array of facts to be operated on.  The long term fact is used on the policy and loaded into memory the first time the policy is called.  The supplied facts are passed out of the called policy with updated / changed values based on the rules inside the policy.  This is very similar to a ByRef call. 



I have put together simple sample that calls the BRE inside .net code using .net objects as facts and a long term fact creator.  Make sure you read the ReadMe.txt file for additional set up information. 



Sample: Biztalk Business Rules With .Net Components Sample



Basically, to run the sample build the two .net assemblies and GAC them.  Then, load the Rule Policy XML using the Rules Engine Deployment Wizard.  Run the WinForm.  Note it may take up to 60 seconds for the policy to first be callable – to bypass this just restart the RuleEngineUpdateService (because you are not really working with BizTalk unless you have to restart a windows service). 



The Long Term Fact will be created once each time you load the form – so if you keep hitting run the LTF gets reused.  I have code commented out that will write to the event log when the LTF is created.



Have fun!

Failed To Load Error When Working With .Net Components In BizTalk Rules Engine

Over the course of the past few weeks, I found several different ways to completely break the Business Rules Engine.  The common error I received is “Failed to Load”.  I received this inside the Policies, Vocabularies, and when Importing the rules from XML.



The error looks something like this:


<IMG src="http://www.biztalkgurus.com/pics/BRE_FailedToLoadPolicy.JPG" P?


So why did this happen?
 


It seems to be caused from two reasons.  Either one of the .net classes used inside the rules or vocabulary has changed (example: you are calling a method called AddCat(String) and now it is AddCat(int)) or the .net assembly is not in the GAC.  The second is easy to fix by GAC’ing the .net components used in the rules.  The first is more difficult. 



To correct the first cause of the Failed To Load problem I have found two ways.  Neither is very elegant. 



The first way to get the vocabulary or policy to load is to manually edit the changed values inside the exported XML version of your rules.  It seems the best thing to do is actually remove the whole function that is causing the problem.  Now, this approach does not work very well unless you have your rules exported as XML. 



The second way to correct this problem does not require the rules to be exported.  It is to change the .net code back, re-GAC it, close the rules composure, reopen it, remove the uses of the code you want to change, save your rules, change your .net code, GAC it, change your rules to use the new .net code.  Simple!



The moral of the story is to be cautious once you start using .net components inside the rules engine.  If you need to make changes to methods used inside the rules, either version your .net code or plan ahead for your changes by removing the usage prior to making the change in the .net code.



Some other things to think about are:



– When working with a remote rules store, all .net components used must be installed locally in the GAC.  Yes, this means that any business user who wants to view or update any rules through the rules composure must have all the .net components on there desktop.  Not only that, they have to be the current version of the .net assemblies or the rules will not load.



– When working with Collections and ArrayLists you need to create your own Add method.  You do not have access to the .Add property on the .net object.



– When deploying rules to the rules store the .net components have to be installed on the local computer.



Do not let this scare you away from using .net components inside your rules or to call your rules purely from .net.  The Business Rules Engine has a lot of powerful features and best of all it is included with BizTalk Server 2004.  Using .net helper classes and objects can greatly simplify rule development and decrease development time.



Updated:  Sorry, original post said increase development time.  I think using .net could help decrease development time.

Interview Answers for Biztalk Server 2004

I guess I was sleeping and forgot to post the answers to the BizTalk Interview Questions from a few posts ago. No worries though, Gustavo Echeverry went thought and answered them complete with reference!  Great work!


In any case, here are my answers.  Of course, in some cases it may be possible to have more then one right answer.


Development Focused Questions


What is BizTalk?


·         Biztalk is a messaging based integration tool.


·         Bonus: It consists of several different pieces including Business Processes (Orchestrations), BAM, Rules Engines, and HAT.


In BizTalk 2002, schemas were DTD based and allowed Xml Elements to be in any order inside a record using the <Any> keyword.  How is this different in BizTalk 2004?


·         BizTalk 2004 is XSD based.


·         BizTalk 2004 Elements default to <Sequence> and <Any> is no longer available.


What is a Message Type (i.e. BTS.MessageType) and how is it used in BizTalk?


·         Message Type is a BizTalk System property that is promoted inside a Pipeline.  It is made up of Document Name Space # Root Node Name.


How do you call a Non-Serializable .Net helper class inside an Expression Shape?


·         Add a reference to that class.


·         Make sure your Orchestration is Long Running transactional.


·         Add an Atomic scope.


·         Create an Orchestration variable of that class inside the scope.


·         Create an instance on that object inside the scope.


·         Call the method.


·         Bonus: Mention the class must be strongly signed and in the GAC.


What if the class is Serializable?


·         No transactional Orchestration or Atomic scope is needed.


What does the Value Mapping Functoid do?


·         Returns the second parameter if the first parameter is true


How do you use Auto Mapping in the BizTalk 2004 mapper?


·         Select a top level node, hold down the Shift key, drag the top level node over to the other top level node.


What is the default mapping for Auto Mapping?


·         The default is by structure.  This can be change to by node name on the map properties. (This default in the auto map messes me up every time.)


Step-by-step, how do you set up a basic, pure messaging solution taking in a flat file and send an Xml File out to 5 different places?


·         Create a Flat File schema


·         Create a Custom Pipeline using the Flat File Disassembler


·         Create a Receive Port


·         Create 5 Send Ports


·         Create a Send Port Group


·         Add each Send Port to the Send Port Group


·         Create a Filer on the Send Port Group using Bts.ReceivePortName (or something close to this)


·         Additional: no map is required but it is ok to mention it


Design (Architecture) Focused Questions


What is the difference between a Distinguished field and a Promoted Property?


·         Distinguished fields are light weight and can only be used inside an Orchestration.


·         Promoted Properties are defined inside a property schema, are tracking in SQL, can be tracked in HAT, and can be used for content based routing.


How do you achieve First-In-First-Out message processing of messages received from multiple sources using an Orchestration?


·         Use a Sequential Convoy to process the messages in the order they are received into the Message Box. 


·         Make sure Ordered Delivery is set to True inside the Orchestration Receive Port.


At high level, what do Receive Ports and Orchestration Send Port really do in terms of messaging?  What about Send Ports and Orchestration Receive Ports?


·         Receive Ports and Orchestration Send Port are both publishers.


·         Ports and Orchestration Receive Ports are both subscribers.


When working with Schemas, Maps, Pipelines, and Orchestrations how should the projects be structured?


·         Schemas and Maps in its own project


·         Or Schemas and Maps together in its own project


·         Orchestrations in its own project


·         Pipelines in it own project


What is direct binding?


·         Direct binding has three types: direct to message box, self correlating, and partner ports.


·         Used to route message between the message box and Orchestrations without using bindings or from one Orchestration to another Orchestration.


What is BAM used for?


·         BAM is used to monitor business milestones and key metrics in near real-time throughout a process in BizTalk.


What is the Rules Engine?


·         Rules are used to provide highly efficient, easily changeable business rules evaluation to Business Processes.  This allows rules to be changed without rebuilding and redeploying .net assemblies.  The Business Rules Engine (BRE) can also be called from any .net component through the API’s.


What are Persistence Points and what causes them?


·         Persistence is when the state of a running Orchestration is stored into SQL.


·         It is good enough to know various shape and actions cause persistence.  More specifically, it occurs: end of a transactional scope, at a send shape, at a start Orchestration shape, during dehydration, if the system shuts down expectedly or unexpectedly, or the business process suspends or ends.


What group does a user need to belong to in order to submit messages to the message box? 


·         The user needs to be a member of the hot group or isolated host group (assuming a default installation).


What user rights to you need to perform most actions in HAT?


·         BizTalk Server Administrator


When installing Biztalk in a multi-server configuration with a remote SQL and Analysis Services, what SQL components do you need on the Biztalk Server?


·         SQL Analysis Services Client Tools


When installing Biztalk and SQL on a Windows XP SP2 Desktop, what pre-requests are required?


·         Correct answer: A Lot.  The best answer something like I have a custom written installation document I use or I always referrer to the most current updated installation guide from Microsoft. 

Visual Studio 2005 Fails To Start

Today I ran into a strange problem.  Visual Studios would not launch!  No matter what I did, it was totally dead.



I had remove Visual Studios 2005 Beta 2 a few weeks ago and upgraded to RTM.  Today, I installed BizTalk 2006 Beta 2 and configured it with no problems.  I went to open Visual Studios to work with BizTalk and nothing happened.



I got the Visual Studio Launch screen for about 5 seconds and then gone.  I could see the program start in the task manger but then it just disappeared.  I was not getting any errors in the event log.



I start by reinstalling VS with no luck.  So, I tried uninstalling and reinstalling VS.  Yep, that took some time; still no luck. 



I then took a look at all my installed programs.  I found two products that I probably should have uninstalled with Beta 2. 



They were:


Windows Workflow Foundations Components for Visual Studios 2005


Software Development Kit for WinFX



I removed both of these items and Visual Studios opened as expected with no problems. 



I’m guessing it was the Windows Workflow that was causing the problem since it was not RTM friendly. 


 


I was surprised that having this installed would actually prevent Visual Studios from running.



So, the moral of the story is make sure you get all the different beta products removed when you upgrade to the RTM of Visual Studios.

Interview Questions for Biztalk Server 2004

Wow, it has been some time now since I last blogged.  I would like to say I have been super busy with tons of project work. But, actually I have been on vacation most of the time.


From time to time I get the chance to interview prospective Biztalk resource to join various projects.  Since Biztalk 2004 is such a broad and relatively new product, it can sometimes be hard to compare different resources that might have had totally different experiences.


I have put together a few questions that I like to use when interviewing possible resources to give you an idea of the types of questions you might get asked in a BizTalk interview.


The point is not to know all the answers but to be able to demonstrate experience with the product and problem solving skills.  I never penalize people for not knowing something as long as they can tell me how they would find out more about it.


At a high level, what should you know in order to be successful on a Biztalk project?


·         General to moderate .net skills


·         Basic SQL skills


·         Debugging skills


·         Understanding of Biztalk development


·         Understanding of Biztalk design (if needed)


Development Focused Questions


What is BizTalk?


In BizTalk 2002, schemas were DTD based and allowed Xml Elements to be in any order inside a record using the <Any> keyword.  How is this different in BizTalk 2004?


What is a Message Type (i.e. BTS.MessageType) and how is it used in BizTalk?


How do you call a Non-Serializable .Net helper class inside an Expression Shape?


What if the class is Serializable?


What does the Value Mapping Functoid do?


How do you use Auto Mapping in the BizTalk 2004 mapper?


What is the default mapping for Auto Mapping?


Step-by-step, how do you set up a basic, pure messaging solution taking in a flat file and send an Xml File out to 5 different places?


Design (Architecture) Focused Questions


What is the difference between a Distinguished field and a Promoted Property?


How do you achieve First-In-First-Out message processing of messages received from multiple sources using an Orchestration?


At high level, what do Receive Ports and Orchestration Send Port really do in terms of messaging?  What about Send Ports and Orchestration Receive Ports?


When working with Schemas, Maps, Pipelines, and Orchestrations how should the projects be structured?


What is direct binding?


What is BAM used for?


What is the Rules Engine?


What are Persistence Points and what causes them?


What group does a user need to belong to in order to submit messages to the message box? 


What user rights to you need to perform most actions in HAT?


When installing Biztalk in a multi-server configuration with a remote SQL and Analysis Services, what SQL components do you need on the Biztalk Server?


When installing Biztalk and SQL on a Windows XP SP2 Desktop, what pre-requests are required?


Please note that knowing that Ctrl-Alt-Z opens the Biztalk Explore when working inside Visual Studios did NOT make my list of questions.

Debatching Design and Performance Considerations Whitepaper

In some business scenarios you may be required to receive a batch file that must be broken up and processed as single messages by BizTalk Server 2004. This could allow for individual record level processing, selective content based routing, or single message mapping.

Get more information from the original blog post on this topic: http://www.biztalkgurus.com/biztalk_server/biztalk_blogs/b/biztalk/archive/2004/12/13/debatching-options-and-performance-in-biztalk-server-2004.aspx 

 

Just Released – BizTalk 2006 Beta 2

The Beta 2 build of BizTalk Server 2006 is now available on Beta Place. 



This also includes a separate download for the Microsoft BizTalk Adapters for Enterprise Applications, also in Beta 2.



You need to be enrolled in the public beta program to have access to this download.


 


An updated BizTalk 2006 Beta 2 installation document and known issues can be found here.



I thought the CTP build was awesome so I can not wait to get this version installed and running.