Book Image

(MCTS) Microsoft BizTalk Server (70-595) Certification and Assessment Guide: Second Edition

Book Image

(MCTS) Microsoft BizTalk Server (70-595) Certification and Assessment Guide: Second Edition

Overview of this book

Table of Contents (20 chapters)
(MCTS) Microsoft BizTalk Server (70-595) Certification and Assessment Guide Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring content-based routing


The following is a walk-through of a routing sample in BizTalk. The sample is done by using the FILE Adapter only, and coding is not done. The next chapter will introduce us to how to create various BizTalk artifacts inside Visual Studio, but for now, let's look at an example showing how BizTalk routes messages.

The setup is as follows:

  • We receive files from both partner A and partner B in different file folders

  • These files need to be routed to both System I and System II

Creating folders and Applications

The first step is to create a Receive Port with two different Receive Locations. We should be able to pick up messages at two different file locations:

  • C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\PartnerA\Inbox

  • C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\PartnerB\Inbox

We should be able to send messages to two different systems (file locations):

  • C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\SystemI\Outbox

  • C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\SystemII\Outbox

Make sure that the BizTalk Host user has sufficient permissions for the folders. Give the user Full control permissions on folder C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop, as shown in the following screenshot:

Tip

The user and/or group doesn't need Full control. It is sufficient to grant the Delete subfolders and files permission found under advanced permissions, along with read and write permissions.

Next, we need to create an Application called BTS2013CertGuide-Ch01. To do this, we need to perform the following steps:

  1. Open BizTalk Administration Console.

  2. Right-click on Applications and then choose New | Application.

  3. Name the new Application BTS2013CertGuide-Ch01 and click on OK.

Creating Receive Ports and Receive Locations

Now, we need to create a Receive Port inside our new Application and add two File Receive Locations, one for each Partner (A and B). In order to do this, carry out the following steps:

  1. In Application BTS2013CertGuide-Ch01, right-click on Receive Ports and choose New | One-way Receive Port.

  2. Name the Receive Port as CG0101_Receive and click on OK.

  3. Right-click on Receive Locations and choose New | One-Way Receive Location.

  4. Select Receive Port CG0101_Receive and click on OK.

  5. Name the location CG0101_ReceiveFromPartnerA_FILE, choose FILE in Transport Type (Adapter), and click on Configure, as shown in the following screenshot:

  6. Configure the FILE Adapter, as shown in the following screenshot, and click on OK (the Receive Folder path is C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\PartnerA\Inbox):

  7. Click on OK again.

  8. Make another Receive Location from steps 3 to 7. Name it PartnerB instead of PartnerA and choose PartnerB file folder instead of PartnerA.

In the Administration Console, our Receive Locations should now look similar to the following screenshot:

Testing the Receive Locations

Now, we need to see that everything is running as intended by testing the solution. In order to start testing, perform the following steps:

  1. Create a small text file, fill it with a few characters, and copy the file into each inbox folder of both PartnerA and PartnerB. The files must consist of at least one character, since the FILE Adapter will throw away empty messages as they do not make sense in a BizTalk perspective. Do not give the files a name containing the word "Copy".

  2. Verify that the BizTalk Host Instance executing the Receive Locations is running.

  3. Right-click on each Receive Location and choose Enable.

  4. Check the Event Viewer and verify that no BizTalk Server errors have been written to Windows Logs/Application when enabling the Receive Locations. If errors are present, examine them, since they are most likely caused by the BizTalk Host user not having sufficient permission in the folders (refer to the Creating folders and Applications section).

  5. Go to FileDrop\PartnerA\Inbox. Copy and paste the file in the same folder so that a copy is inserted, and confirm that BizTalk deletes the file. It might be quick, so watch closely!

  6. If the file is deleted by BizTalk, our PartnerA locations are working. Do the same test PartnerB.

Debugging the messages

Now, let's examine what happened to the messages we submitted to BizTalk.

  1. Upon opening Event Viewer again, you should find four errors (two for each message submitted).

  2. Open the last error submitted in Event Viewer, it should look something similar to the following screenshot:

What BizTalk is telling us here is that even though the receive processing of the messages was successful, the messages could not be routed because there were no subscribers. In other words, neither Send Ports nor Orchestrations were created with a subscription matching the Context of the messages.

Now, we will examine the Context of one of the messages that failed to be routed:

  1. Go to Group Hub by clicking on the BizTalk Group folder in the Administration Console, then press F5 to refresh the dashboard showing in the right pane.

  2. We should now see four suspended items:

  3. Click on the Resumable link.

    Tip

    The Non-resumable instances are primarily there for debugging purposes. They show the Context as it appeared after Port processing, whereas the Resumable instances show the message and the Context as it appeared before Port processing.

    In this example, the promoted properties are the same for both instances, and we can therefore use the Resumable instance. If properties had been added during Pipeline processing and/or mapping, we would need to examine the Non-resumable instance.

    Also, note that the Non-resumable instance will disappear by itself if the Resumable instance is resumed successfully.

  4. Double-click on one of the suspended items.

  5. Choose the Messages tab, and double-click on the message.

  6. Choose Context, and click on Type twice so that the promoted properties are shown on top.

  7. Examine the five promoted properties. These are the only properties we can use for subscription for now. The best candidate for subscription might be the ReceivePortName with the value of CG0101_Receive.

Setting up a Send Port

Now, we will perform the following steps for creating a Send Port that subscribes to all messages where ReceivePortName has the value of CG0101_Receive in its Context:

  1. Create a new Send Port by right-clicking on the Send Port folder and navigating to New | Static One-Way Send Port.

  2. Fill in Name and Type. Click on Configure.

  3. Fill in the Destination folder path (C:\BTS2013CertGuide\Chapter01\Example01-Messaging\FileDrop\SystemI\Outbox) and the File name, as shown in the following screenshot, and click on OK:

  4. Choose the Filters page. Select BTS.ReceivePortName in the Property drop-down list. Leave Operator as == and type the Receive Port name in the Value textbox.

  5. Click on OK.

  6. Start the Send Port by right-clicking on it and choosing Start.

  7. Submit a message from either Partner A or Partner B.

  8. Check that System I gets a file in the outbox folder.

  9. Go back to Group Hub, choose the two resumable suspended items, and right-click and choose Resume Instances. Click on Yes, and then click on OK.

  10. Verify that the two additional files are now in the System I folder.

Setting up Send Port for System II and a Send Port Group

System II also needs a copy of all messages received by the Receive Port. So instead of making two Send Ports with identical filters, we will make a Send Port Group with the subscription for the Receive Port name, and then add both Send Ports to the group.

  1. Create a new Send Port for System II following the same steps we did when creating the first Send Port, with SystemII in its name instead of SystemI. Also, use the SystemII outbox folder instead. Don't give the new Send Port any filter.

  2. Start the Send Port.

  3. Create a new Send Port Group by right-clicking on the Send Port Group folder and choosing New | Send Port Group….

  4. Give the group a name, as shown in the preceding screenshot, and add the two Send Ports to the group.

  5. Give the group a filter with the Receive Port name, just as we did with the first Send Port.

  6. Click on OK.

  7. Right-click on the group and start it.

  8. Submit a message from one of the partners.

  9. Notice how System II got one message, but System I got two. This is because a Send Port inside a Send Port Group will have two subscriptions both its own subscription and the Group subscription. If both of them are met, the Port will receive the same message twice.

  10. Go to the System I Send Port and remove the subscription inside the Filter page by pressing Delete. Click on OK.

  11. Test again; this time System I should only get one copy.