Introduction

For BizTalk there is the option to schedule receive location (start date, end date and time) and send port start and end time (service window). But there is no flexibility when it comes to scheduling at specific time on a daily, weekly or monthly basis.

There are other approaches besides the option within BizTalk to provide means of scheduling:

  • Using Windows Task Scheduler to drop a file to the specified receive location
  • Using SQL Adapter by implementing a simple stored procedure that creates a "dummy" message that initiate your orchestration
  • Using BizTalk Scheduled Task Adapter

This article intends to show how we can schedule a process using the BizTalk Scheduled Task Adapter. The following scenario is used to demonstrate the steps required for scheduling.

Problem statement: See the forum question

BizTalk Scheduled Task Adapter

The BizTalk Scheduled Task Adapter is an in-process receive adapter that executes a prescribed task on a daily, weekly or monthly schedule. The adapter is configured entirely within BizTalk, all configurations are stored within the SSODB and can be exported and imported via binding files. 

The schedule capabilities are similar to those available with the Windows Scheduled Task Service.

Four simple tasks are included:

  • XmlStringStreamProvider - generates a BizTalk message from a configured Xml string
  • FileStreamProvider - generates a BizTalk message from the contents of a file
  • HttpDownload - generates a BizTalk message from data downloaded from a web site 
  • SQLStreamProvider - generates a BizTalk message from the contents of a SQL Query

Download the adapter from : http://biztalkscheduledtask.codeplex.com/

Installation guide : http://sandroaspbiztalkblog.wordpress.com/2012/06/12/biztalk-scheduled-task-adapter-4-0-introduction-and-installation-process/

Solution

The solution comprises of an orchestration which would process order messages, but this orchestration will become active only when trigger message is published into message box. And to publish the trigger message Scheduled Task adapter is used.

Designing the application

  1. Two schemas – one for Order and for the TriggerMessage 
  2. The orchestration to receive the trigger message and initializing the correlation based on ReceivePortName. Thus this orchestration will pick all the messages coming from the same port until the loop condition is satisfied

Configuring the application

The application needs two receive locations – one for receiving order message and another one with a schedule for Trigger message.

  

RLOrderFile: Receive location to receive files on which processing is to be done.

RLTriggerFile: Receive location from where the trigger file will be received

With the schedule task adapter there is provision to trigger file from file on File System, data in SQL, data from web service and xml string.

       

Under General provide the Name of the schedule you are configuring 


Configure the schedule, set the start date and time frame, when you want the schedule to become active. Under Schedule type you have options - time span, daily, weekly and monthly. For the example in this article, have used time span of 2 hours.


The Task tab asks you to provide the class which has the code which converts the trigger file into BizTalk message. Which can be find at Program Files/BizTalk ScheduleTask Adapter


After selecting the class, you need to choose the method of receiving trigger message, for this article FileStreamProvider is used as trigger message is picked from file location.

Against the Filename provide the path where your trigger file will be

Now configure the orchestration

          

How it works

The reason behind the scheduling of a process is the requirement to run it at a specific point of time. The orchestration has its processing designed but it's activation is restricted by introducing Trigger message. And with the help of Scheduled Task adapter a trigger message is dropped in MessageBox as per the schedule set on it which instantiates the orchestration which later on processes all the actual messages coming from same receive port with the help of correlation.

  •  Trigger message is picked from receive location by the adapter as per the schedule
  •  Converts it to BizTalk messages and drops into MessageBox
  •  Orchestration which subscribes to this trigger message gets activated
  •  After activation orchestration performs it's intended job of processing the order messages.  

    Download the sample : Scheduling Orchestration using Trigger Message

Author

Maheshkumar S Tiwari|http://tech-findings.blogspot.in/

See Also

Another important place to find an extensive amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.