This post is in continuation with the series “Replaying failed messages from BizTalk ESB Portal”
If you haven’t seen the first post of this series, please use the below link to view the post. Part 1
In this Post, we will see a sample application. This solution will comprise a schema and an orchestration. We will see how we can route messages to the ESB from an orchestration. After doing this excercise we will also see how we can route failed messages from receive port and send port to the ESB.
So, lets first see how we can route messages from Orchestration.
- I created a sample application to demonstrate this. I have a xml schema which will be my source schema. The schema structure looks like this.
- I added the below dll’s as reference to the 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
- Added an orchestration which will process the xml message. It receives the xml message using a receive shape and tries to assign the promoted value(Count) into a variable.
- As I explained in my previous post, I have added a scope that will have all my shapes. Currently there is only one shape in our business process. 7.Create a message in orchestration view and name it msgFaultMessage. Select the type as
- 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 = “Process Questions”; msgFaultMessage.FaultCode = “”; msgFaultMessage.FaultDescription = ex.Message; msgFaultMessage.FaultSeverity = Microsoft.Practices.ESB.ExceptionHandling.FaultSeverity.Critical; Microsoft.Practices.ESB.ExceptionHandling.ExceptionMgmt.AddMessage(msgFaultMessage,msgQuestion);
- 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.
- Build the project and deploy the orchestration. Now to see the fault message routed to ESB, we need to create a source file for our orchestration to receive and process. Go ahead and generate an instance of the xml message. Modify the message and remove the value for the Count field. This will make the orchestration engine throw an error. That error which will caught by our exception handler and a fault message will be created. It will then be sent to Message box using direct send port.
- This is what you should in the BizTalk administration console.
- See how the message is showing up in ESB portal.
- You can click on the fault message to show its fault details in the fault viewer.
- You can find a grid at the bottom and this is the actual failed message. You can see a link for its messageid and if you click that it will give you a chance to see it message data and its context properties.
Below is the message data
Below is the context data
In this post I have explained how to route failed messages to ESB and see the fault messages within ESB Management console.
Messages can also be routed from receive ports and send ports. There is a check box in the properties and we can enable that to route fault messages to the message box.
In the next post, I will show you how to replay messages from the BizTalk ESB console.