Today, I will bring back to life another old BizTalk Server blog post by an old friend of mine, Thomas Canter, with his permission, that I find pretty interesting and useful: Checking for the existence of a property. This was initially published on http://geekswithblogs.net/ThomasCanter, now retired.
NOTE:
The variable PropExists as bool has already been created
The Property of interest is BTS.RetryCount
The Message is Message_In
The list from Using Operators in Expressions (https://learn.microsoft.com/en-us/biztalk/core/using-operators-in-expressions) has the typical list of stuff that you expect in C#, multiplication, bit operations (shift left and right), and Boolean operators, but a couple of extremely useful constructs are available that are unique to BizTalk.
The most important of these (in my humble opinion) is the exists operator.
As you are all aware, to even check whether a property exists in an expression throws an exception… as in the following case:
If BTS.RetryCount does not exist in the message context, then the MissingPropertyException (Windows Event Log Event ID 10019) is thrown.
Without having to resort to a scope shape and exception handler, the exists operator allows you to check if a property exists in a message and is used in the following format:
PropExists = BTS.RetryCount exists Message_In;
OR
if (BTS.RetryCount exists Message_In)
{
…;
}
Conclusion
Using the XLANG/s exists operator in your orchestration allows you to test for the existence of a property in a message without resorting to a scope shape and exception handler.
Below are a few more XLANG/s functions that can provide some value to your Orchestrations:
Operator
Description
Example
checked()
raise error on arithmetic overflow
checked(x = y * 1000)
unchecked()
ignore arithmetic overflow
unchecked(x = y * 1000)
succeeded()
test for successful completion of transactional scope or orchestration
succeeded()
exists
test for the existence of a message context property
BTS.RetryCount exists Message_In
Hope you find this helpful! So, if you liked the content or found it helpful and want to help me write more content, you can buy (or help buy) my son a Star Wars Lego!
Author: Sandro Pereira
Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.
He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira
As you most likely are aware, when a document is received by a BizTalk Server adapter, the adapter creates a BizTalk message for the document. The BizTalk message contains the document that was received as well as a message context. The message context is a container for various properties that are used by BizTalk Server when processing the document. Each property in the Message Context is composed of three things, a name, a namespace, and a value.
Message context properties are added to the message context throughout the lifetime of the message as it passes through the BizTalk Server. These properties:
Are either extracted from the message itself, for example, order id or shipment number
Or added by pipelines and adapters at the receive location, for example, transport name or receive port name
There are mainly two benefits of this context:
The first is to provide the various components of BizTalk, an easy access to these properties, without having to parse the message
The second is to support content-based routing.
There are two different types of message context properties used by BizTalk as described below:
Distinguished Fields
Property Fields.
In this whitepaper, you will learn the key differences between Distinguished and Property Fields but most importantly you will have access to a complete list of known property schema and properties used internally by the BizTalk Server out-of-the-box components.
What’s in store for you?
This whitepaper will give you a detailed understanding of the following:
BizTalk Message Context Properties
What are Property fields and how to promote properties?
What are distinguished fields and how to create a distinguished field?
Summary of differences between Property Fields and Distinguished Fields
System property schema and properties
Error Report property schema and properties
Legacy schema and properties
Microsoft BizTalk XLANGs BTXEngine schema and properties
Message Tracking schema and properties
BizTalk Framework Schema and Properties
MIME-SMIME Property Schema and Properties
XML and Flat File Property Schema and Properties
File adapter property schema and properties
FTP Adapter Property Schema and Properties
HTTP Adapter Property Schema and Properties
MQSeries Adapter Property Schema and Properties
MSMQ Adapter Property Schema and Properties
POP3 Adapter Property Schema and Properties
SMTP Adapter Property Schema and Properties
SFTP Adapter Property Schema and Properties
SOAP Adapter Property Schema and Properties
SQL Adapter Property Schema and Properties
WCF Adapters Property Schema and Properties
Windows SharePoint Services Adapter Property Schema and Properties
Azure Service Bus Adapter Property Schema and Properties
Azure Blob storage Adapter Property Schema and Properties
Azure Event Hubs Adapter Property Schema and Properties
Office 365 Outlook Calendar Adapter Property Schema and Properties
Office 365 Outlook Contact Adapter Property Schema and Properties
Office 365 Outlook Email Adapter Property Schema and Properties
SharePoint Online Adapter Property Schema and Properties
Microsoft BizTalk Accelerator for HL7 (BTAHL7) Property Schema and Properties
How to write or promote properties in the context of a messages through the BizTalk API