BizTalk ESB: Exception Handling in Orchestration

here is how to use Exception Handling framework from Orchestration

This post is about couple of errors that consumed lots of time to figure out when testing an implementation that uses ESB Exception Handling framework.

in windows event log (BizTalk ESB Toolkit 2.1):

Object reference not set to an instance of an object.

Source: Microsoft.Practices.ESB.ExceptionHandling.PipelineComponents.ProcessFault

Method: Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext, Microsoft.BizTalk.Message.Interop.IBaseMessage)

Error Source: Microsoft.Practices.ESB.ExceptionHandling.PipelineComponents

Error TargetSite: Void WriteHeaderFailedMessageRouting(System.Xml.XmlTextWriter, Microsoft.BizTalk.Message.Interop.IBaseMessage, System.Object ByRef) 

Error StackTrace:    at Microsoft.Practices.ESB.ExceptionHandling.PipelineComponents.ProcessFault.WriteHeaderFailedMessageRouting(XmlTextWriter writer, IBaseMessage pInMsg, Object& portName)
   at Microsoft.Practices.ESB.ExceptionHandling.PipelineComponents.ProcessFault.WriteHeader(XmlTextWriter writer, XmlTextReader reader, FaultSource faultSource, IBaseMessage pInMsg, Object& portName)
   at Microsoft.Practices.ESB.ExceptionHandling.PipelineComponents.ProcessFault.Execute(IPipelineContext pContext, IBaseMessage pInMsg)


// Add the message to the Fault Message
Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(MsgFaultMultipart, MsgInboundMessage);

this line is required in Orchestration code for ProcessFault pipeline component to work.


in windows event log:

xlang/s engine event log entry: Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service (a42d0855-ec7c-3dc7-5e9f-442c84746e85)’.

The service instance will remain suspended until administratively resumed or terminated.

If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.

InstanceId: 003a57d2-42b3-4a20-8cfa-a03b810df217

Shape name: Send_1

ShapeId: ad8c422b-4b45-41c5-bd0b-5ce958491e1e

Exception thrown from: segment 5, progress 8

Inner exception: Exception occurred when persisting state to the database.

Exception type: PersistenceException

Source: Microsoft.XLANGs.BizTalk.Engine

Target Site: Void Commit()

The following is a stack trace that identifies the location where the exception occured

   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.Commit()

   at Microsoft.XLANGs.Core.Service.Persist(Boolean dehydrate, Context ctx, Boolean idleRequired, Boolean finalPersist, Boolean bypassCommit, Boolean terminate)

   at Microsoft.XLANGs.Core.ServiceContext.PendingCommit(Boolean ignore, XMessage msg)

   at Microsoft.XLANGs.Core.ExceptionHandlingContext.PendingCommit(Boolean ignoreCommit, XMessage msg)

   at Microsoft.XLANGs.Core.ExceptionHandlingContext.PendingCommit(Boolean ignoreCommit, XMessage msg)

   at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation, XLANGMessage msg, Correlation[] initCorrelations, Correlation[] followCorrelations, Context cxt, Segment seg, ActivityFlags flags)

   at XX.segment5(StopConditions stopOn)

   at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

Additional error information:

        A batch item failed persistence Item-ID 5f10694f-5a1f-4b05-ab88-6c9edbd1140d OperationType MAIO_CommitBatch Status -1061151998 ErrorInfo The published message could not be routed because no subscribers were found. .

Exception type: PersistenceItemException

Additional error information:

        Failed to publish (send) a message in the batch. This is usually because there is no one expecting to receive this message.  The error was The published message could not be routed because no subscribers were found.  with status -1061151998.

Exception type: PublishMessageException



1. Add Microsoft.Practices.ESB in your Application’s References

2. configure a SQL send port with ProcessFault pipeline component to insert exception in ExceptionDB.

(Alternatively, we can use All.Exceptions send port that was created with ESB Core installation)

17-Sep-12 12-24-36 PM

BizTalk ESB Toolkit 2.1: Index (zero based) must be greater than or equal to …

After installation and configuration of ESB Toolkit 2.1, ESB Portal gives this error.  I tried to debug ESB.Portal solution but unfortunately Microsoft does not provide source code for BizTalk Operations Service and we are left with trying different options.

The reason in this case was that BizTalk Operations Service Application Pool user should be member of BizTalk Administrator group (or some other BizTalk group who has permissions to retrieve list of installed BizTalk applications.