Software

Working with scheduled jobs in the OutSystems Agile Platform

Justin James describes how simple it is to create scheduled tasks (or Timers) in the OutSystems Agile Platform. You can set a Timer's schedule, priority, action, and more.

 

Read the previous installments in the series: Getting started with the OutSystems Agile Platform, Learning the basics of the OutSystems Agile Platform, Describing the OutSystems Agile Platform Service Studio experience, Working with the OutSystems Agile Platform's Integration Studio, Deploying an application created with the OutSystems Agile Platform, and Adding ECT to an eSpace with the OutSystems Agile Platform.

One of Rat Catcher's major differentiators compared to similar products is the idea that it can create a report on a regular basis that shows the user where their documents have appeared on the Internet. Scheduling tasks in Web-based applications is not usually the most pleasant thing in the world.

One way to do it is to completely separate your application from the logic so that you can write a lightweight application to handle the scheduled tasks and call it on a schedule. Another approach is to write a service or a daemon that has a scheduling component. Alternatively, you can put the code in a Web page and call that page from the operating system's scheduler. Some systems use a "poor man's cron," where when a page is called in the application and there are pending tasks to be run, a secondary process is launched to run the tasks. But no matter how you look at it, the traditional options for having batch processing are not appealing and require additional configuration. In the Agile Platform, task scheduling is built-in and using it is a smooth and natural extension of the rest of the work.

In the Agile Platform, scheduled tasks are known as Timers. Creating a Timer is very easy. In the eSpace's tree, there is a node for them, and you create a new one like you would any other new item in the eSpace. The Timer has some properties (Figure A) that you will want to set to ensure that it works the way you need it to:
  • Schedule: This controls how frequently the Timer performs the associated Action.
  • Priority: If there are multiple Timers scheduled for the same time, the Priority attribute determines which ones take precedence.
  • Action: This determines what will happen when the Timer is fired; if you choose an Action with arguments, you will be able to set those as well.
  • Timeout in Minutes: A Timer can be set with a Timeout, so the scheduling system knows to cancel it if it has run for too long.
Figure A

The properties of my SendQuotaEmails Timer.
One disappointment is that your scheduling options are fairly simplistic (Figure B). OutSystems has recently asked the community for feedback, and improving the scheduling was on the list of things that people have suggested (you must log in to access this page). Figure B

The Timer schedule options are adequate, but they could be a bit more in-depth.
For my current needs, I will create two Timers. The first Timer will look at all of the user accounts, find out how many documents are going on their schedule, see if they are close to their limit, and send the account administrator a "heads up" email. What makes this Action work well is that I added a Boolean attribute to my entity for accounts that indicates if an over quota email had been sent (Figure C). When I do send an email, I set this attribute to True. Any accounts that are currently under the quota have this flag set to False. I also modified my account upgrade process to reset this attribute to False; that way, the emails are only sent once, but will always be sent once an account is over quota. Figure C

The Action that handles sending "over quota" emails.

On a side note, the Envelope icon in Figure C is to send an email message, which is one of the very nice features of the Agile Platform. In some systems I have used, you need to create email templates and then populate a collection of values and have the email template filled with macros to substitute values from the collection. In the Agile Platform, you design an email just like a Web page, and it can have its own logic and accept parameters as needed. In this case, my email message takes the account's ID as an argument and has a Preparation Action that looks up all of the needed information to fill out the email. Within the email, you use the same Widgets that you use for the Web screens to display the data you pull. As a result, working with emails is very pleasant and consistent with the rest of the system.

The second Timer will run the nightly reports (Figure D). This was pretty easy to do. First, I loop through all of the accounts and look for accounts that have the current day as their day of the month to run reports. The way I handle reports is that I generate a REPORT entity with all of the needed information with a list of JOB_TASK entities (each one represents a document and its related settings) associated with the REPORT. For the scheduled reports, I copy the information for the JOB_TASKs from a SCHEDULED_JOB_TASK entity, which is what the user manipulates when they edit their scheduled reports; this way, archived reports show the settings that were used to run the report, not the currently selected settings. Once the REPORT entity is created, I call the same RunReport function that I call when a user runs an ad-hoc report. Finally, I email the account administrator and let him or her know that the report was run and include a link to the report. Figure D

The RunScheduledReports Action is pretty straightforward.

I may create a third Timer to perform the monthly billing. Some credit card gateways can perform recurring billing automatically. If I were to allow the gateway to handle the recurring billing, it would take a bit of the load off of my back in terms of worrying about storing credit card numbers and the associated security concerns with that. It is not that I do not trust myself or the Agile Platform, it is a simple matter of risk mitigation. Why store sensitive data and make yourself a target for hackers if you can help it? But if I allow the credit card gateway to handle the recurring billing, I will need to add gobs of logic to change the billing information as users upgrade and downgrade accounts; it would definitely be far less effort to just have a billing Action that pulls the proper number on a monthly basis and charges that. And, I already have this logic built into my ACCOUNT entity anyway.

I will be making a decision about this third Timer soon. The billing situation, the overall "look and feel," and making the system self-explanatory are my big remaining challenges before I can start marketing Rat Catcher as a full-blown product.

J.Ja

Disclosure of Justin's industry affiliations: Justin James has a contract with Spiceworks to write product buying guides; he has a contract with OpenAmplify, which is owned by Hapax, to write a series of blogs, tutorials, and articles; and he has a contract with OutSystems to write articles, sample code, etc.

About

Justin James is the Lead Architect for Conigent.

8 comments
Jaqui
Jaqui

what are the requirements to use the platform? can't find that info on their website.

verelse
verelse

The proliferation of "frameworks" these days is astounding. What compelling reason would an organization have to employ yet another scheduling framework? I am not advocating a position here, I just want to understand why there are 1500 frameworks for every simple coding task?

Jaqui
Jaqui

found out it's winders only.

Justin James
Justin James

The Agile Platform is not a framework, it is an entirely different kind of tool, IDE, development model, etc. This article discusses only one small aspect of it (its Timer functionality). J.Ja

Justin James
Justin James

The tools themselves are Windows only, unfortunately. The Platform Server which hosts the final product can be Linux. J.Ja

Justin James
Justin James

... that when you are talking about *desktop* tools, the Linux market is usually too small to justify the time, effort, and expense. It's even smaller when you talk about desktop BSD. And it's *even* smaller for their target audience, which is primarily enterprise developers. Besides, you know that there is no good way to do cross platform GUI'ed tools without any of the frameworks or libraries you shun and hate anyways, like Qt. :) J.Ja

Jaqui
Jaqui

Dear Jaqui, Thank you for sending us your feedback at www.outsystems.com . I would like to tell you that feedback from our users is extremely important and that I have already forwarded your comment to our product management team. As an answer to your question, though there are no plans to support most of the platforms you referred, one of the deployment options of the OutSystems Agile Platform is Linux over ORACLE. The OutSystems Agile Platform supports the following configurations: * Microsoft Windows + SQL Server (running ASP.Net over the Microsoft Internet Information Services) * Microsoft Windows + ORACLE (running ASP.Net over the Microsoft Internet Information Services) * Linux + ORACLE (running J2EE over the JBOSS application server) I would just like to point out that one of the characteristics of the OutSystems Agile Platform is the fact that it tries to abstract as much as possible the technical details of your environment ? you develop in an end-to-end visual environment and you applications are deployed as standard web applications in the environment you are running (ASP.Net of Java over ORACLE or SQL Server). The management can then be done using a management console for auditing, troubleshooting, analytics, etc. You can read all the details at http://www.outsystems.com/agile-platform . To get an idea of the type of applications and benefits that you can get from the OutSystems Agile Platform, you can read case studies of past OutSystems projects at http://www.outsystems.com/case-studies. If infrastructure is the problem that you are facing, I would like to tell you that there are several options for the deployment of our software: * Deployment in the Amazon Cloud ? In order to make it trivial for you to create an instance of the OutSystems Agile Platform Community Edition in the Amazon EC2 service, OutSystems has already created images of the OutSystems Agile Platform in the Amazon cloud. See the forum topic How-to Install the Agile Platform Community Edition in the Amazon Cloud and read step-by-step instruction on how to setup your OutSystems Agile Platform instance. You will have to have an Amazon EC2 account to do this. In case you have any question, you can simply post it in that forum thread. * Using other cloud hosting services - The OutSystems Agile Platform is compatible with cloud hosted servers (like Amazon EC2 and GO GRID). You can create your server in your preferred cloud hosting service and install the OutSystems platform there. * Using virtualization software - The OutSystems Agile Platform is fully virtualization software (like VM Ware). If you have a server available, you can create a virtual server and install the OutSystems Agile Platform in that server * Installing the OutSystems platform in a in-house server - of course, you can also setup a physical web server in-house and install the OutSystems platform there. Kind regards, Daniel Louren?o OutSystems --------------------------------------------- IN RESPONSE TO YOUR COMMENTS AT WWW.OUTSYSTEMS.COM DATE: 2010/08/25 YOUR COMMENT: When will you have it for other operating systems? in a 1000% Free Software / Open Source Software network, your windows only tools are useless. there are 7 BSD flavours, GNU/Linux, MacOS, AIX, HPUX and Solaris that you are ignoring. The first 8 are the ones I have available to me. [ 7 BSDs and GNU/Linux ] and my response: You missed the point entirely. I DO NOT have, nor will I purchase, WINDOWS. if the agile platform DEVELOPMENT TOOLS do not run on the operating systems I mentioned, then I cannot use the Agile Platform at all. can't develop with it if the tools don't work for me. and Java itself is a no-go. it is extremely environmentally unfriendly because of it's worship of Hardware is Cheap development model. More hardware means higher power consumption means more POLLUTION. so Hardware is Cheap development model is a forbidden model for my systems, no Java, no .NET, no application frameworks at all. so I guess your platform is designed to deny the possibility of me ever using it.

Jaqui
Jaqui

when you don't have windows the tools are useless. I sent them an email: I guess you don't want my bussiness, I only have GNU/Linux or the 7 BSDs as operating systems and you don't make the tools that I can use. :D

Editor's Picks