Replaying failed messages from BizTalk ESB portal Part 1

This was a new learning for me from this current contract. The ESB portal is an ASP.Net application which can be used to replay the messages. Then comes the question, can I replay a message with its original context property? Yes, you can, but hold on, you need to customize the ESB Portal application given by Microsoft and you need to create a custom pipeline component and a custom pipeline. So first let’s see how we can replay a message without context properties.

I want to split this topic into multiple parts, as one post will get rather big to accomodate all the topics.

Replaying messages without context properties

I have jotted down the steps required in bullet points, as everyone(including me) like points rather than story.

  1. When you Install Biztalk in the development environment, you would have got the ESB Portal application Installed and configured. If not, use the below link to complete that.
  2. AFter you have intalled and configured ESB Portal, navigate to the ESB portal website, to make sure there is no issues. It should like the below picture.
  3. Please also make sure that you have installed the ESB Biztalk application which comes with the SDK. You should have an application like this.
  4. The Above application is also required if you have to use ESB Toolkit in your development. This application has reusable orchestrations, pipelines which can be used for various scenarios. If you watch the send ports, you will see a SQL send port. By default it points to a local SQL server. If your ESBExceptionDb is installed in the local sql server, then you dont need to change this setting. However if it is a different instance then you need to change this value to the correct SQL instance. One more thing to note here is that, this send port has filters which subscribes to the ErrorReport and ESb property schema. See the below picture.
    So any messages that is sent to the BizTalk mesasge box with these fields promoted will be subscribed by the send port and it will be routed to the ESB Exception DB.
  5. The Next step is to add logic in your code to route messages to the message box, so that the messages are sent to the Exception Db.There are two ways to do it.
    A) Enable the “Failed routing for failed messages” in Receive Port for routing failed messages in the receive pipeline to the ESB. You can also tick the check box “Enable routing for failed messages” in the Send port advanced properties. When a message gets failed for any reason, it will be routed to the ESB framework. B) You can add logic in the orchestration to route messages to the ESB.
  6. To route the message to the ESB framework, the general principle is to first add a scope shape in your orchestration and add all your other shapes within the scope shape. Now add a Exception block to this shape and choose a System.Exception as the exception type.
    Add the two dlls are reference to the orchestration project.

    C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit 2.1\Bin\Microsoft.Practices.ESB.ExceptionHandling.dll
    C:\Program Files (x86)\Microsoft BizTalk ESB Toolkit 2.1\Bin\Microsoft.Practices.ESB.ExceptionHandling.Schemas.Faults.dll

  7. Create a message in orchestration view and name it msgFaultMessage. Select the type as
  8. Add a construct shape and select the message that we have just added. Add a message assignment shape and the below code.

    msgFaultMessage = Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.CreateFaultMessage();
    msgFaultMessage.FailureCategory = “BizTalk Fault Message Testing”;
    msgFaultMessage.FaultCode = “”;
    msgFaultMessage.FaultDescription = ex.Message;
    msgFaultMessage.FaultSeverity = Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Critical;

  9. Add a send shape to send the fault message. Add a Logical send port in the orchestration and configure the binding as Direct with “Routing between ports…” option selected.
  10. If you test your orchestration now(Add some logic to make the orchestration fail), A fault message will be created and it will be routed to the ESB framework. You can try opening the ESB portal and navigate to the Faults Menu and your fault will appear there. You can click the fault message to get the full details of the fault in the Fault Viewer page. It will give you the Exception Message.
  11. This still doesn’t show the actual message that was failed. It will gives us information about the fault. To route the failed message to the portal, you need to add one more line to the message assignment shape.

    where the msgInputMessage is the message that your orchestration receives from your source system.

  12. Re-build your code, deploy and see if you can now see the fault message appearing in the Faults Page.

In the next post we will see how we can replay the message with a sample application.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s