Click here to Skip to main content
15,888,610 members
Articles / Programming Languages / XSLT

Exception Handling With Ports in BizTalk

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
25 Dec 2007CPOL3 min read 34.3K   23  
Exception handling with Ports in BizTalk

Introduction

One of the interfaces that we developed for our client had the following requirement.

Send the output file to the target location using Dynamic send port. If Output file is already present at the target location, then send the file to Backup location using a Static send port. If file is already present at backup location, then catch the exception and send the file to error location using Static send port.

We'll cover the technical implementation in the following sections, with each subsequent section (optionally) making use of the previous section’s implementation.

Schemas, MAP and Pipelines

In order to implement this solution, we have used the following schema, Map and Pipelines:

  1. Schema: EmpData.xsd
  2. Map: EmpTO Emp.btm
  3. Receive Pipeline1
  4. Send Pipeline1

Create one receive and three send ports in the orchestration in the orchestration view.

Here we will cover the creation of Dynamic send port.

2.2 Creating Dynamic Port and Exception Handling

Please see the below images for creating Dynamic send port:

  1. Create a port type in orchestration view (e.g. PortType_DyanamicSend)
  2. Add new port in orchestration view and configure the Port using Configuration Wizard:

  3. Drag an expression shape from the tool bar and write the following code in the expression shape:
    C#
    {
    DynamicSend(Microsoft.XLANGs.BaseTypes.Address) = @"file://E:TempOUT" + strFilename;
    }

    This will create the dynamic port for you after deploying the orchestration.

    (Note: Please note that we can read the transport type and Location from Configuration Section. Here I have hard coded transport type and location in the orchestration for simplicity.)

To handle the exception, Set the Property Delivery Notification = Transmitted for each port you have created in orchestration view.

The exception object we need to construct is of type Microsoft.XLANGs.BaseTypes.DeliveryFailureException.

Now deploy the solution containing schemas, pipeline, orchestration.

Perform the following steps:

  1. Create one Receive port in BTS explorer (e.g. DynamicPortExp.Receive with one receive Location.
    DynamicPortExp.Receive.File with File as transport type and e:dataIn as file drop location).
  2. Create two send ports in BTS explorer (e.g. DynamicportExp.Send.File with backup location as e:databackup and DynamicPortExp.Send.Error.file with error location e:dataError with transport type as File).
  3. Now drop the file (e.g. Emp1.txt) at Input location after processing through orchestration it reaches to a location specified by dynamic send port, e.g. E:TempOUT.
  4. Once again drop the same file at input location as the file is already present at location specified by dynamic send port. It will throw a Delivery failure exception. We are catching this exception in the catch block of the orchestration. After logging this exception in the event viewer, the file is sent to backup location.
  5. Again drop the same file at input location. After processing orchestration, try to send the file at location specified by dynamic port. As file is already present at the location, it raises an exception and tries to send the file at backup location but file is also present at backup location. So we are expecting that orchestration will send this file to an error location but it will not send the file to error location and we will see the following warning message in the event viewer and orchestration will not catch the exception.
  6. In order to catch the exception for static send port, the trick here is to set the retry count(default –3) and retry interval(default –5) property of send port to Zero(0) as shown below.

To find more articles written/posted by me, please visits my blog at http://biztalk-ssis-ssas.blogspot.com.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United Kingdom United Kingdom
My primary skill set comprise of EAI, ETL and EDI with immense experience in Microsoft BizTalk v2004/2006/R2, Web Services, .net v2.0/3.0 (WCF, WWF), SQL Server 2000/2005 (SSIS/SSAS/BIDS). I have very good proficiency with the BizTalk 2004/2006, SSIS, SS Service Broker, Workflows and MS SOA supportive technologies like WCF/MSWSE 2.0, with thorough knowledge of various Integration System Development Strategies like integration patterns, EAI concepts, B2B integration and securities, SOA. Specialties: BizTalk v2004/2006/R2, SSIS, SSAS, .net 2.0/3.0, WinCF, WinWF, Host Integration Server 2004/2006

Personal Technology Blog: http://biztalk-ssis-ssas.blogspot.com/

Comments and Discussions

 
-- There are no messages in this forum --