This has come up on the BizTalk Forum a few times lately. Sometimes, there’s a requirement where we have to send a notification when nothing happens. By far, the most common scenario, BizTalk wise, is when a file doesn’t appear at the expected location.
So, how do we know that something doesn’t happen?
While there are several patterns that could address this depending on scope of the application, I think the easiest way is to wait for a specified amount of time and if you don’t hear from the sender, take some action.
This article describes how to create a simple Watcher Orchestration that listens for a specific Message Type, waits for an interval, and creates some notifications if that interval expires before receiving another Message.
The Watcher Orchestration is basically just a Sequential Convoy that does no meaningful business processing. When the initial message hits the MessageBox, a new instance of the Watcher Orchestration is activated. It then goes into a Loop containing a Listen
Shape that either Received the Following Messages or waits for a specified timeout period.
If the Following Message arrives first, the Loop continues and the timer is reset.
If the timeout fires first, it sends an alert message and Terminates.
When a new Message is eventually received, the process starts over again.
The Orchestration is constructed as a basic Sequential Convoy.
And here are all the Orchestration Designer items:
In this example, the Receive Port is Direct bound and the Request Message is our Daily file. This causes the Port's Subscription to include the MessageType so we will receive a copy of any instance of the Daily message. If you only want to monitor a single
Receive Port, Change the Binding to Specify Later and set the port binding in BizTalk Administrator. This is not a case where Ordered Delivery would make a significant difference in function, so it’s left False.
The Correlation Type consists of only BTS.MessageType.
The two Receive Shapes Initialize then Follow the Correlation Set.
A typical scenario is to receive a file or other message on a daily basis. Here, I configured the Delay Shape to wait for 25 hours, one day plus some time to allow for differences in delivery time.
Finally, if the Delay Shape fires, we take some action. Here, I use a Map to generate a simple Alert message and publish directly to the MessageBox where any Send Port can subscribe. These Send Ports can be the file system, e-mail, SharePoint or any other
destination. Alternatively, you can use an Expression Shape to write an Event Log Entry that can be picked up by SCOM.
There are many ways to customize or enhance this pattern. For example, using a custom Pipeline Component, you can make the Watcher Orchestration generic enough to handle many different Ports or MessageTypes without copying or recompiling. The timeout can
be customized to work at any interval or time of day.
Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is
BizTalk Server Resources on the TechNet Wiki.