- Microsoft BizTalk Server 2010 Patterns
- Dan Rosanova
- 1493字
- 2021-04-02 18:21:57
Core guidance
This section contains core guidance principles for BizTalk best practices. Most of these will be a little on the abstract side and therefore serve more as recommendations than as best practices per se, but I strongly believe in all of them.
Determining where to place different types of logic
In Chapter 2, Introduction to BizTalk Development, we looked at the architecture of the BizTalk platform and the basic components involved in a solution. Now we will focus more on these components themselves and present suggestions and patterns for them. The first involves deciding where to place logic within the solution structure that we saw in the previous chapter.
A common problem that BizTalk developers face is determining exactly where in a solution to house different parts of their logic. This can be a fairly complex issue that can result in paralysis by over analysis. I wish I could say there was an easy answer, but finding the right balance is really more of an art than a science, and all I can do is offer some basic guidelines.
Maps
Maps are a common place to put a lot of logic in a BizTalk solution and it can be a good place. The problem comes, however, with scalability in terms of the growth of large maps and the extension of logic placed within them. It can be hard to track down where a logical decision is being made in BizTalk, when it takes place in a map. Appropriate uses of pages, notations, and documentation can alleviate this, but maps are mostly meant for translation, not for the embodiment of business logic. In fact, avoiding placing business logic in maps is really considered a best practice within the BizTalk community. One benefit to putting logic in maps is that fixes can be made by simply GAC-ing a new assembly and restarting the affected host instances. This can provide low (or no) downtime patching. This generally is not a good enough reason to place logic in maps. Maps are really intended only to perform translation between formats.
Orchestrations
Being graphical, workflows that have similarities to flowchart's orchestrations often seem very familiar to us as developers, even more so with Windows Workflow now in the marketplace, but stuffing too much logic into orchestrations is not a good practice. Orchestrations are focused on message handling, but the decision and looping shapes providing familiar programming constructs to work with and many programmers quickly, equate these with decision and looping constructs in programming languages. The greatest downside of overusing these is that your orchestration canvas grows very large very quickly and making changes becomes cumbersome. Even working in a team environment becomes more difficult in these circumstances. This is similar to creating large methods in C#; it's just not a good practice. Orchestration is not the programming language of BizTalk and should not be treated as a programming language; it is one part of the entire platform that is BizTalk.
Business rules
Not a lot of people use the Business Rules Engine (BRE) in BizTalk and I cannot say I know why, but it could be due to a lack of real world examples and cryptic documentation. I don't believe this tool ever lived up to its original promise of a business analyst friendly tool, but it certainly lives up to my expectations of an effective way to encapsulate logic into a solution in a loosely coupled manner. This is because the rules themselves are deployed independently from the BizTalk solutions that use them. This means they can be updated without changing the solutions that use them. If you have complex decision logic, this is a great tool to implement it. Used correctly, BRE can help you create extensible solutions that can be extended without recompiling your entire solution.
The BRE is an ideal place for logic that is used for routing, and business decisions such as pricing or discounts. There is also the classic example of credit scoring. The BRE is meant to address more rapidly changing logic than orchestration shapes would provide. My favorite way to use BRE is to call rules with XML documents; ideally providing them with all the information they will need, so that they do not need to make external lookups. This focuses the rules on business rule logic rather than on lookup or database logic.
Pipelines and pipeline components
Pipelines are one of the least understood areas of BizTalk, but deserve a lot more credit and attention than they often receive. Almost any .NET component can be called in a custom pipeline component such as BAM and BRE, but great care must be taken not to interfere with the memory model used by BizTalk. Pipeline components can also be used to promote properties or check for duplicate messages. Almost the entire ESB Toolkit for BizTalk is implemented via pipeline components. This allows the developer to use these already created components for a variety of tasks throughout BizTalk from mapping to itinerary processing. Even in the included tool set, pipelines can be used to determine parties and promote or demote properties. Pipeline components are a good example of real reuse in BizTalk, but unfortunately pipelines themselves often are not reused. The parameters for a pipeline can be set in the BizTalk Administration console and they can be set separately for specific receive locations or send ports. This allows us to create a single pipeline that can be reused in multiple places by simply changing the configuration. If less is indeed more, this is a great way to achieve it.
General concept
Ultimately, I believe the downfall of any part of a BizTalk solution is complexity. You should never try to put too much logic into a single place. This is a design tenant well known in OOP—Single Responsibility Principle—but it is one that is easy to lose sight of when working on any platform and BizTalk is no different. BizTalk's graphical focus can actually make this more difficult to avoid at first, as well as the fact that it is not as granular as OOP by nature. Often, if a design is too complex, it should be broken into smaller designs. This advice serves well for maps, orchestrations, rules, and even pipeline components.
Mapping at the port level
As we have seen in our solution architecture so far, it is important to isolate our internal, canonical formats from the outside world; that is external formats. This advice is extremely important, even if all the systems involved in the communication are controlled by a single development team. This is critical because any schema exposed by BizTalk is in essence a public interface. Public interfaces are a contract that may need to be supported for a long time. Any change to a public interface may break calling applications, and BizTalk will be unaware of these implications; yet, just as in traditional programming, we want to be free to change the implementation behind any interface.
The solution is to always map messages going into or out of BizTalk, so as to never let external dependencies bleed in, or internal details seep out of a solution. If your solution is very simple and will never have more than a single calling system and will never ever have to change over time, you may not need to use this technique. The effort required to use maps at the port level is indeed small and it is worth the extra effort to be prepared for the changes that inevitably come to all software programs.
To see this in action, imagine that we create a simple solution receiving a message, routing on some part of the content, and then transforming (mapping) this message as we send it out of BizTalk. If we now have to make this solution work with another inbound message format, we need to route on the new message's content and create another map for sending the message out. If our solution uses business rules or orchestration, this makes it even more work to add a second format; it would also affect our BAM.
What we're trying to do is isolate our solution from changes in other external systems, or requirements. Mapping on both the receipt and send of a message isolates our internal solution from changes in the outside world. The following is an example of the chain connected, travelling through BizTalk and being mapped at both ends of the chain.

The isolation enforced by this pattern guarantees that no external dependencies will leak into or out of the solution. Our routing, orchestration, and business rules, and even our BAM tracking, are isolated from the outside world. They will be easier to manage and change as a result. Anything between the maps can be changed or implemented in a different way and the external interfaces and endpoints will not need to change at all. This is an effective example of decoupling.
- Moodle 1.9 for Teaching 7/14 Year Olds: Beginner's Guide
- Cinema 4D電商美工與視覺設(shè)計案例教程(培訓(xùn)教材版)
- Drupal: Creating Blogs, Forums, Portals, and Community Websites
- iPhone User Interface Cookbook
- 零基礎(chǔ)學(xué)會聲會影2018(全視頻教學(xué)版)
- Visio圖形設(shè)計從新手到高手(兼容版)
- PostgreSQL 9.0 High Performance
- Backbone.js Cookbook
- 剪映短視頻剪輯從入門到精通:宣傳短片+電商視頻+產(chǎn)品廣告+活動慶典
- TopSolid Wood軟件設(shè)計技術(shù)與應(yīng)用
- Photoshop CS6圖像處理立體化教程
- OpenGL 4.0 Shading Language Cookbook
- TYPO3 4.3 Multimedia Cookbook
- SolidWorks 2020中文版入門、精通與實戰(zhàn)
- Alfresco 3 Cookbook