Can you activate an orchestration based on time interval? RRS feed

  • Question

  • Hi,

    I need an orchestration to fire every hour. I know I could create a dummy message and have it passed every hour, but has anyone ever been able to do this within the orchestration?

    Wednesday, May 7, 2008 7:34 PM


All replies

  • Yes, this is a good example of where you might use the scheduled task adapter. This is available for free on CodePlex: http://www.codeplex.com/BizTalkScheduledTask.



    Wednesday, May 7, 2008 8:20 PM
  • To do this "within the orchestration" you'd probably be looking at a singleton that had a delay shape and triggered the target orchestration every hour.  However, as mentioned, the Scheduled Task adapter is probably a cleaner way to go ...

    Sunday, May 11, 2008 9:49 AM
  • Has anyone actually used this? I ran through the install but I am not sure how to set it up. All I want to do is run my orch every 1 hour. Anyone have a detailed way to implement this?


    Tuesday, June 10, 2008 2:26 PM
  • There is a problem with this adapter's documentation if you have moved past VS.NET 2003 Sad

    Basically after the install has run you need to add an adapter via Biztalk Admin Console, - navigate to the Adapters -> Add, Name= Schedule, Adapter = Schedule.

    After that add a receive location, select the Type = Schedule, Configure

    Provide a name, a schedule (ellipsis button) and task(ellipsis button)

    Tuesday, June 10, 2008 6:24 PM
  • I have indeed moved on... Smile


    Ok I got all that done, now I am just wondering what the Task is looking for? Can I remove the original file recieve shape from my orch and replace with the schdule one? Or do I need to leave the orch as is and then just use this adapter to pass the file I want?


    Thanks for your help


    Tuesday, June 10, 2008 6:34 PM
  • The tasks are just simple .NET classes, you can write your own or use one of the three canned ones. You need to browse to the ScheduledTask.TaskComponents.dll when setting up the task.

    The easiest one is the XmlString, where you can enter the Xml for the message you wish to receive. The file receive task will read a file from disk This is non-destructive, doesn't remove the file. And there is an Http task that will download a file given a URL.

    The adapter simply sends the Xml from the task as a message to Biztalk, and this adapter will replace the original file receive location.


    Tuesday, June 10, 2008 6:55 PM
  • Just keep in mind this adapter has some problems. I wouldn't rely on it in production. Custom windows service is more reliable.

    Wednesday, June 11, 2008 3:50 PM
  • Paul,

    I have been using the Scheduled Task Adapter in a number of implementations for some years without problem.

    Can you give me a list of the problems with this adapter?

    Wednesday, June 11, 2008 9:40 PM
  • Let me clarify this statement. There is actually one particular problem I faced with it - schedules with long intervals sometime cause multiple event triggering near scheduled time or can be few seconds late.


    I think the reason is not in the adapter itself but rather in the API it depends on. As I see your adapter uses Microsoft.BizTalk.Scheduler.TaskTrigger class which in turn uses System.Threading.Timer. Quick look through the source code tells that there's no re-synchronization point between Timer and system time while TaskTrigger is in Armed state. The Timer is reset only at scheduled event interval (it uses ISchedule.GetNextActivationTime()). But threading timer and system clock can go out of synch (because it's not real-time OS timer). So it is possible, that timer event arrives a bit earlier than expected system time and triggers scheduled event. Look at the TaskTrigger timer elapsed event handler:


    public override void OnTimerElapsed(TaskTrigger trigger)
        Memento memento = (Memento) trigger.memento;
        memento.TimerSet = false;
            if (!trigger.auto)
                memento.ActivationTime = trigger.schedule.GetNextActivationTime();
                memento.TimerSet = true;



    Notice how Trigger naively accepts that current event time is past scheduled time. It simply requests next time from the Schedule and arms the timer again. If actual time of method execution is before originally scheduled time the Schedule will return closest next scheduled time which is going to be the same time it was just armed before. It may be just few hundred milliseconds in the future from the current moment but that will cause timer to fire again almost immediately. It can double or even triple fire depending on how far thread time is out of synch.


    When I design scheduling services around System.Threading.Timer, I simply add ArmedSync state to the trigger and arm timer for some configurable interval (for example 5 sec). In this state trigger checks and resets timer time against system time until it closes on scheduled time. Then it will transition into ArmedLaunch state. In this state it invokes task only if current event time is equal or greater (past) scheduled time. This allows reliable precise long running schedules.

    Thursday, June 12, 2008 1:35 AM
  • Thanks, for that Paul. Might see what can be done to fix this, now that have a bit more time available.


    Thursday, June 12, 2008 11:02 AM
  •  Greg.Forsythe wrote:

    Thanks, for that Paul. Might see what can be done to fix this, now that have a bit more time available.



    No problem, Greg. I have some ideas so if you need help let me know.

    Thursday, June 12, 2008 3:52 PM