In the previous article, I explained what is host throttling and what are the mitigation strategies to avoid reaching throttling condition.
Since Publishing throttling state = 4, we increased the process memory threshold, but this led to another problem. The host instance started generating an "out of memory" error. Microsoft recommends that if an "out of memory" error is raised by increasing the Process memory usage threshold, then consider reducing the values for the Internal message queue size and In-process messages per CPU thresholds. And in worse case, if your BizTalk server regularly runs out of virtual memory, then consider BizTalk Server 64-bit.
Showing posts with label BizTalk Server 2006. Show all posts
Showing posts with label BizTalk Server 2006. Show all posts
Tuesday, February 17, 2009
Tuesday, December 30, 2008
XML parsing error: Not enough storage is available to complete this operation
We had a stored procedure which was running fine in the production environment until recently, just out of the blue, we started getting the following SQL exception:
The adapter failed to transmit message going to send port "SendPort1" with URL "SQL://testsvr/testdb/". It will be retransmitted after the retry interval specified for this Send Port. Details:"HRESULT="0x80040e14" Description="The statement has been terminated."
HRESULT="0x80040e14" Description="XML parsing error: Not enough storage is available to complete this operation."
The stored procedure was using sp_xml_preparedocument to insert data from an xml source into the database. The data size was approximately 10MB.
We went through a lot of posts, some of which suggested restarting the server; which obviously is not the solution for the production environment. We tried out a simple trick which worked in our case. Execute the following command on Sql server:
dbcc freeproccache
This command is primarily used to clear the procedure cache.
The adapter failed to transmit message going to send port "SendPort1" with URL "SQL://testsvr/testdb/". It will be retransmitted after the retry interval specified for this Send Port. Details:"HRESULT="0x80040e14" Description="The statement has been terminated."
HRESULT="0x80040e14" Description="XML parsing error: Not enough storage is available to complete this operation."
The stored procedure was using sp_xml_preparedocument to insert data from an xml source into the database. The data size was approximately 10MB.
We went through a lot of posts, some of which suggested restarting the server; which obviously is not the solution for the production environment. We tried out a simple trick which worked in our case. Execute the following command on Sql server:
dbcc freeproccache
This command is primarily used to clear the procedure cache.
Tuesday, November 25, 2008
How to change the file name of the SMTP Attachment in BizTalk
To change the file name of the SMTP Attachment in BizTalk:
myMessage(MIME.FileName) = “test.txt”
myMessage(MIME.FileName) = “test.txt”
BizTalk Server Host throttling
We faced a performance issue in BizTalk some time back. As a result of bulk operations due to financial closing at year-end, a lot of messages were in a dehydrated state and the processing was too slow. As usual Googling led to Performance tips and tricks provided by Microsoft. The first step in such investigations, as rightly pointed out, is obviously identifying the bottleneck, which in our case was the BizTalk Tier. To identify bottlenecks, we monitored a few performance counters. As the article suggests, we started with Message Delivery Throttling State and the Message Publishing Throttling State performance counters and immediately we caught hold of the culprit! Host Throttling Performance Counters gives a complete listing of all performance counters that can be monitored to identify such bottlenecks.
Message Publishing Throttling State was 4 which means Throttling due to process memory pressure. The possible values are as follows:
0: Not throttling
2: Throttling due to imbalanced message publishing rate (input rate exceeds output rate)
4: Throttling due to process memory pressure
5: Throttling due to system memory pressure
6: Throttling due to database growth
8: Throttling due to high session count
9: Throttling due to high thread count
11: Throttling due to user override on publishing
I will discuss the measures taken to overcome this issue later in this article, but, what we first need to look at is, what is host throttling. This is what Microsoft says:
To manage the use of resources by a host instance process, BizTalk Server utilizes an adjustable throttling mechanism that governs the flow and processing of messages through a host instance. The throttling mechanism moderates the workload of the host instance to ensure that the workload does not exceed the capacity of the host instance or any downstream host instances. The host throttling mechanism also detects when available resources are being underutilized. It helps to ensure that the system operates at an optimal and sustainable level. This mechanism continually monitors for a throttling condition, calculates the severity of the throttling condition, and applies host throttling progressively depending on the calculated severity. The throttling mechanism is self tuning and the default configuration options are suitable for the majority of BizTalk Server 2006 processing scenarios. For example, if inbound throttling is applied to a receive adapter then the receive adapter may stop receiving messages until the throttling condition is mitigated. For details, read What Is Host Throttling? Host throttling configuration parameters are set on a per host basis in the BizTalk Server Administration console.
How BizTalk Server Implements Host Throttling provides a mitigation strategy for each of the above throttling conditions. Since throttling was due to process memory pressure, we increased Process memory usage threshold for the host, as suggested in the article. By default, it is 25%. What this really means, is that, a throttling condition will be triggered when process memory usage exceeds 25% of the total available process memory (The maximum available process memory is capped at an address space size of 2 GB) i.e., 500MB. We increased it to 35%, which means that, throttling condition will be triggered only when process memory usage exceeds around 700 MB. In our case, the actual process memory usage was 630MB, which is more that 500MB, which resulted in a throttling condition. Increasing the threshold resulted in mitigation of throttling condition and the messages were immediately proccessed.
This also meant that, with increasing number of BizTalk applications, one host instance would not be enough and such issues would reoccur. This prompted us to introduce an additional host instance. Now we have two host instances, one that is used for real-time applications and another, that is used for scheduled applications.
Message Publishing Throttling State was 4 which means Throttling due to process memory pressure. The possible values are as follows:
0: Not throttling
2: Throttling due to imbalanced message publishing rate (input rate exceeds output rate)
4: Throttling due to process memory pressure
5: Throttling due to system memory pressure
6: Throttling due to database growth
8: Throttling due to high session count
9: Throttling due to high thread count
11: Throttling due to user override on publishing
I will discuss the measures taken to overcome this issue later in this article, but, what we first need to look at is, what is host throttling. This is what Microsoft says:
To manage the use of resources by a host instance process, BizTalk Server utilizes an adjustable throttling mechanism that governs the flow and processing of messages through a host instance. The throttling mechanism moderates the workload of the host instance to ensure that the workload does not exceed the capacity of the host instance or any downstream host instances. The host throttling mechanism also detects when available resources are being underutilized. It helps to ensure that the system operates at an optimal and sustainable level. This mechanism continually monitors for a throttling condition, calculates the severity of the throttling condition, and applies host throttling progressively depending on the calculated severity. The throttling mechanism is self tuning and the default configuration options are suitable for the majority of BizTalk Server 2006 processing scenarios. For example, if inbound throttling is applied to a receive adapter then the receive adapter may stop receiving messages until the throttling condition is mitigated. For details, read What Is Host Throttling? Host throttling configuration parameters are set on a per host basis in the BizTalk Server Administration console.
How BizTalk Server Implements Host Throttling provides a mitigation strategy for each of the above throttling conditions. Since throttling was due to process memory pressure, we increased Process memory usage threshold for the host, as suggested in the article. By default, it is 25%. What this really means, is that, a throttling condition will be triggered when process memory usage exceeds 25% of the total available process memory (The maximum available process memory is capped at an address space size of 2 GB) i.e., 500MB. We increased it to 35%, which means that, throttling condition will be triggered only when process memory usage exceeds around 700 MB. In our case, the actual process memory usage was 630MB, which is more that 500MB, which resulted in a throttling condition. Increasing the threshold resulted in mitigation of throttling condition and the messages were immediately proccessed.
This also meant that, with increasing number of BizTalk applications, one host instance would not be enough and such issues would reoccur. This prompted us to introduce an additional host instance. Now we have two host instances, one that is used for real-time applications and another, that is used for scheduled applications.
Tuesday, April 22, 2008
Interesting stuff about BizTalk Server 2006 Business Rules Engine
I came across some interesting stuff about BizTalk Business Rules Engine and thought that I could consolidate my findings here with appropriate references. I have tried to list all references as far as possible, but it could be possible that I have missed out some since I had done this research quite a long time back.
Inserting xml nodes using Business rules
The Microsoft.RuleEngine assembly that ships with Microsoft BizTalk Server 2006 has a class named XmlHelper, which allows you to insert nodes into an XML document from an action in a business rule and set their values.
You can find a sample here.
Usage of static .NET objects in Business Rules
You can build business rules that only require stateful objects to be passed in as facts, and leave helper functions, lookups and the like as static objects.
For example, using standard "DateTime.Now" function contained in the mscorlib assembly, without passing an instance of that object into the rule as a fact.
The following key is required in the registry to use static objects in Business rules: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BusinessRules\3.0\StaticSupport (DWORD)
There are three valid values for this key:
0 - This is the default key, and pretty much mimics the behavior of BizTalk Server 2004 where an instance of an object is always required as an input fact, and the method is only called when the rule is evaluated or executed.
1 - An instance of the object is NOT required, and the static method is called whenever the rule is evaluated or executed
2 - An instance of the object is NOT required, but the static method will be called at rule translation time (only if the parameters are constants). This is primarily meant as a performance optimization. However, note that static members used as actions will NOT be executed at translation time, but static methods used as parameters may be.
Select 1. Restart machine after adding the registry entry.
Reference: http://www.topxml.com/rbnews/BizTalk-Rule-Engine/re-21606_BizTalk-Server-2006-Business-Rules-and-Static-Methods.aspx
Parameter list does not appear inside the "Call Rules" shapes "Configure Policy" dialogue box with in the Orchestration
This is one problem that you weface frequently while developing BziTalk applications. When you create a Vocubularty Definition for XML element or attribute, with "Add New Definition" wizard. After selecting the Schema file, you make sure the "Document Type" text box has same namespace as that of the schema. This is not the target namespace of the schema but the namespace of schema file. You can check this namespace in Properties of the schema file.
For example: if the namespace of the Schema is "IFRC.SI.VoiceCallsToCODA.SCH" and schema type name = "GetTelephoneCostDistribution" , then you need to set the "Document Type" value to "IFRC.SI.VoiceCallsToCODA.SCH.GetTelephoneCostDistribution".If you are not doing this step correctly, parameter list won't appear in the "Call Rules", "Configure Policy" dialogue box.
Don't set context properties while in messages while working with Business Rules
BRE actually creates a new message and sends that back to the calling orchestration. Therefore, the existing one really gets overwritten, so, be aware of that when you set context properties. If you set context properties on a message, then pass that message into a business rule, those properties disappear.
An orchestration sets up the SMTP.Subject context property on the message, and then calls a rule to set some additional message fields up. Finally, I send the message out through the SMTP adapter. As expected, the message shows up in my mailbox without a subject (actually, the message GUID was entered as the subject).
If I add a Construct shape after the Call Rules shape and reset the SMTP.Subject, then when the message is sent out through the adapter, the mail shows up in my Inbox with the dynamically set subject line.
So, be careful when setting context properties for dynamic behavior if you are also using the BRE. It's probably a best practice to set context properties as late in the process flow as possible (i.e. directly before a Send shape).
Sorry I do not remember the source for this one, nonetheless, I have found a good article with a sample on Richard Soretor's blog. You will find very interesting articles on his blog for BizTalk Server.
Modifying vocabulary after it is published and used in business rule
It can be quite irritating at times to create and publish a new version of a vocabulary once the previous version is used in a business rule, particularly in development environment. I managed to find a workaround for this by manipulating some records in BizTalkRuleEngineDb tables. But I would strongly recommend that this be tried only in development environment and not in production environment.
Inserting xml nodes using Business rules
The Microsoft.RuleEngine assembly that ships with Microsoft BizTalk Server 2006 has a class named XmlHelper, which allows you to insert nodes into an XML document from an action in a business rule and set their values.
You can find a sample here.
Usage of static .NET objects in Business Rules
You can build business rules that only require stateful objects to be passed in as facts, and leave helper functions, lookups and the like as static objects.
For example, using standard "DateTime.Now" function contained in the mscorlib assembly, without passing an instance of that object into the rule as a fact.
The following key is required in the registry to use static objects in Business rules: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\BusinessRules\3.0\StaticSupport (DWORD)
There are three valid values for this key:
0 - This is the default key, and pretty much mimics the behavior of BizTalk Server 2004 where an instance of an object is always required as an input fact, and the method is only called when the rule is evaluated or executed.
1 - An instance of the object is NOT required, and the static method is called whenever the rule is evaluated or executed
2 - An instance of the object is NOT required, but the static method will be called at rule translation time (only if the parameters are constants). This is primarily meant as a performance optimization. However, note that static members used as actions will NOT be executed at translation time, but static methods used as parameters may be.
Select 1. Restart machine after adding the registry entry.
Reference: http://www.topxml.com/rbnews/BizTalk-Rule-Engine/re-21606_BizTalk-Server-2006-Business-Rules-and-Static-Methods.aspx
Parameter list does not appear inside the "Call Rules" shapes "Configure Policy" dialogue box with in the Orchestration
This is one problem that you weface frequently while developing BziTalk applications. When you create a Vocubularty Definition for XML element or attribute, with "Add New Definition" wizard. After selecting the Schema file, you make sure the "Document Type" text box has same namespace as that of the schema. This is not the target namespace of the schema but the namespace of schema file. You can check this namespace in Properties of the schema file.
For example: if the namespace of the Schema is "IFRC.SI.VoiceCallsToCODA.SCH" and schema type name = "GetTelephoneCostDistribution" , then you need to set the "Document Type" value to "IFRC.SI.VoiceCallsToCODA.SCH.GetTelephoneCostDistribution".If you are not doing this step correctly, parameter list won't appear in the "Call Rules", "Configure Policy" dialogue box.
Don't set context properties while in messages while working with Business Rules
BRE actually creates a new message and sends that back to the calling orchestration. Therefore, the existing one really gets overwritten, so, be aware of that when you set context properties. If you set context properties on a message, then pass that message into a business rule, those properties disappear.
An orchestration sets up the SMTP.Subject context property on the message, and then calls a rule to set some additional message fields up. Finally, I send the message out through the SMTP adapter. As expected, the message shows up in my mailbox without a subject (actually, the message GUID was entered as the subject).
If I add a Construct shape after the Call Rules shape and reset the SMTP.Subject, then when the message is sent out through the adapter, the mail shows up in my Inbox with the dynamically set subject line.
So, be careful when setting context properties for dynamic behavior if you are also using the BRE. It's probably a best practice to set context properties as late in the process flow as possible (i.e. directly before a Send shape).
Sorry I do not remember the source for this one, nonetheless, I have found a good article with a sample on Richard Soretor's blog. You will find very interesting articles on his blog for BizTalk Server.
Modifying vocabulary after it is published and used in business rule
It can be quite irritating at times to create and publish a new version of a vocabulary once the previous version is used in a business rule, particularly in development environment. I managed to find a workaround for this by manipulating some records in BizTalkRuleEngineDb tables. But I would strongly recommend that this be tried only in development environment and not in production environment.
- Export the existing version of the vocabulary into xml file.
- Create a new version of the vocabulary and add/modify the needed definitions.
- Export the new version of the vocabulary into xml file.
- Copy the modified/added definitions in new version to xml file of the old version.
- Go to BizTalkRuleEngineDb database of the BizTalk Server.
- Open table re_vocabulary and get nVocabularyID column of your vocabulary.
- Open table re_ruleset_to_vocabulary_links and get nReferingRuleset for nVocabularyID fetched in previous step.
- Delete all rows in re_ruleset_to_vocabulary_links containing nVocabularyID as your vocabulary id.
- Delete entry in re_vocabulary containing nVocabularyID as your vocabulary id.
- Import the existing version vocabulary file.
- Insert entries into re_ruleset_to_vocabulary_links for all rule sets fetched in step 7 with the new nVocabularyID .
Monday, April 21, 2008
Known Issues with SQL Adapter in BizTalk Server 2006
UnexpectedMessageTypeException
Problem:
Microsoft.XLANGs.Core.UnexpectedMessageTypeException: Received unexpected message type '' does not match expected type '[MESSAGE TYPE]'.
at Microsoft.XLANGs.Core.PortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.VerifyTransport(Envelope env, Int32 operationId, Context ctx)
at Microsoft.XLANGs.Core.Subscription.Receive(Segment s, Context ctx, Envelope& env, Boolean topOnly)
at Microsoft.XLANGs.Core.PortBase.GetMessageId(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject location)
at [ORCHESTRATION NAME] (StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
Solution:
Make sure that the XML send/receive pipelines have been configured for the physical port.
Passing DateTime value as input parameter to stored procedure
Problem:
The adapter "SQL" raised an error message. Details "HRESULT="0x80040e07" Description="Error converting data type nvarchar to datetime "".
Solution:
Change the data type of the input parameter to string.
If you create the schema for the concerned stored procedure using Add Generated Items wizard, it will create the input parameter with data type as string. Don't change the data type to datetime.
Refer the following link for further information:
http://msdn2.microsoft.com/en-us/library/aa578440.aspx
Refer the following link for Best Practices for the SQL Adapter
Problem:
Microsoft.XLANGs.Core.UnexpectedMessageTypeException: Received unexpected message type '' does not match expected type '[MESSAGE TYPE]'.
at Microsoft.XLANGs.Core.PortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.VerifyMessage(Envelope env, String typeName, Context cxt, OperationInfo op)
at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.VerifyTransport(Envelope env, Int32 operationId, Context ctx)
at Microsoft.XLANGs.Core.Subscription.Receive(Segment s, Context ctx, Envelope& env, Boolean topOnly)
at Microsoft.XLANGs.Core.PortBase.GetMessageId(Subscription subscription, Segment currentSegment, Context cxt, Envelope& env, CachedObject location)
at [ORCHESTRATION NAME] (StopConditions stopOn)
at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)
Solution:
Make sure that the XML send/receive pipelines have been configured for the physical port.
Passing DateTime value as input parameter to stored procedure
Problem:
The adapter "SQL" raised an error message. Details "HRESULT="0x80040e07" Description="Error converting data type nvarchar to datetime "".
Solution:
Change the data type of the input parameter to string.
If you create the schema for the concerned stored procedure using Add Generated Items wizard, it will create the input parameter with data type as string. Don't change the data type to datetime.
Refer the following link for further information:
http://msdn2.microsoft.com/en-us/library/aa578440.aspx
Refer the following link for Best Practices for the SQL Adapter
Subscribe to:
Posts (Atom)