Step-by-Step BizTalk Auto Scheduler
The following is a list of some solutions for triggering BizTalk processes based on a schedule.
I have implemented, in one way or another, most of the approaches outlined in Michael’s article above.
Sandro has created the ultimate Schedule Task solution, but often I work at customers that will not allow any custom code to run in their environment.
At a recent client, we ended up implementing an approach that uses the Scheduling features in BizTalk Server Feature Pack 1or 2 and the WCF SQL Adapter.
Ingredients:
- WCF-SQL Receive Location
- BizTalk Server Feature Pack 1, or preferably, Feature Pack 2 to support time zones
Step-By-Step
- Create a new WCF-SQL static one-way receive port and associated location.
Notice a critical element--that the Receive Pipeline is a Pass Through Receive. Do not attempt to disassemble this; we are going to throw it away.
- Create the associated Receive Location.
Now comes the tricky part… the WCF-SQL Configuration.
- Connect to a database
Go ahead and point at the BizTalk Management Database. The BizTalk Service Account always has access to this, so you won’t need to go through any security configuration.
- And the tricky part here is, create a polling data available statement that always returns a non-zero value, but never actually hits the database.
Then, create the polling statement that returns something. We don’t care what it is.
PolledDataAvailableStatement: SELECT 1 as PollData
PollingIntervalInSeconds: Set this to about 5 minutes, or something fairly large. We want only one PollStatement to occur during the polling window.
PollingStatement: Select 1 as PollStatement
Ok, so now we have a Receive location that will always fire, at the beginning of a polling window.
Later, we have to carefully make the polling window small, less than the PollingIntervalInSeconds so that it only fires once in the window.
- Now we configure the Polling Schedule. Here are the default settings.
We need to enable the Schedule. Verify that the Start date is enabled, and is a date prior to the Start that I want to set.
- In this example, I want this to fire every weekday, at 9:00 AM Central European Standard Time, with an adjustment for Daylight Savings Time:
Now, this schedule will fire only once, at 9:00 AM on a weekday.
The output message is a simple XML statement, that contains the value "1" from the Polling statement. You should have your downstream component fire, consume a generic XML Document, and ignore the content; just run when it receives an event from a message for BTS.ReceiveLocation == "Schedule1 Receive Port".
I believe that this approach handles most of the requirements for scheduling events in BizTalk in a highly reliable, controlled manner.
Here is the list of scenarios from Toon’s article, and I see this approach can handle each one:
- Send a specific message every x seconds / minutes.
- Trigger a process every x seconds / minutes.
- Poll a rest endpoint every x seconds / minutes.