Alerting in BizTalk

Suppose you don’t use BizTalk360 and you want a send a mail every time an error occurs. In that case, you can create an orchestration. The orchestration starts with an activating receive. The message received is of type Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.FaultMessage. The activating receive uses the following filter: ErrorReport.FailureCode Exists Or Microsoft.Practices.ESB.ExceptionHandling.Schemas.Property.FaultCode Exists The next step is to lookup the mail adres for the specific faultcode. Typically you will have different support engineers for functional and technical errors. Blow example uses an expression shape, but you can also use a business rule. Lookup mail adres bij FaultCode: EmailAddress = SqlLookUpHelper.LookupEmailByErrorCode(MsgFaultMessage.FaultMessage.FaultCode); The next steps is to create a fault message to be mailed. In this case we use a message assignment shape with the following content: MsgFaultMessageMail.FaultMessage = MsgFaultMessage.FaultMessage; MsgFaultMessageMail(*) = MsgFaultMessage(*); MsgFaultMessageMail(SMTP.Subject) = “Er is een fout opgetreden”; MsgFaultMessageMail(SMTP.EmailBodyText) = MsgFaultMessage.FaultMessage.FaultDescription; MsgFaultMessageMail(SMTP.EmailBodyTextCharset) = “UTF-8”; MsgFaultMessageMail(SMTP.MessagePartsAttachments) = 1; MsgFaultMessageMail.FaultMessage(MIME.FileName) = “OriginalMessage.xml”; MsgFaultMessageMail.FaultMessage(Microsoft.XLANGs.BaseTypes.ContentType) = “text/xml”; Then you have to set the mail address for the STMP port. To this end we set a promoted property on the (dynamic) sendport: MailEsbFaultPort(Microsoft.XLANGs.BaseTypes.Address)=”mailto:”+EmailAddress; The final step is to send the message. Like mentioned before, we use a dynamic send port. <SendPort Name=”ErrorHandling.SP.MailEsbFault.Dynamic” IsStatic=”false” IsTwoWay=”false” BindingOption=”4″> <Description xsi:nil=”true” /> <TransmitPipeline Name=”Microsoft.BizTalk.DefaultPipelines.PassThruTransmit” FullyQualifiedName=”Microsoft.BizTalk.DefaultPipelines.PassThruTransmit, Microsoft.BizTalk.DefaultPipelines, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ Type=”2″ TrackingOption=”None” Description=”” /> <ReceivePipelineData xsi:nil=”true” /> <Tracking>${ErrorHandling.SP.EsbFaultMail.Dynamic.Tracking}</Tracking> <Filter /> <Transforms /> <OrderedDelivery>false</OrderedDelivery> <Priority>5</Priority> <StopSendingOnFailure>false</StopSendingOnFailure> <RouteFailedMessage>false</RouteFailedMessage> <ApplicationName>Kw1c.BizTalk.ErrorHandling</ApplicationName> </SendPort> Go to the send handler of the SMTP adapter and set the Exchange Server.