By | 06 June 2012

PeopleSoft Daemon Application Engine Example

There is an Application Engine process type that is called a daemon. This is a special process type that “continuously” runs in the background looking for certain conditions and if the conditions are met, it will trigger something. Generally, this “something” is another process. We have continuously in quotes because it runs on a heartbeat and is not running in an infinite loop. Here are some examples of things that could be monitored:

  • The existence of a file on a server
    • Vendor files
    • Error files
  • The existence or non-existence of data in the database

The daemon application engine type is not documented very well in PeopleBooks. It is actually a pretty simple concept. Let’s walk through an example.

Let’s say that we have vendor that will post a file to an FTP directory at any time during the day. The vendor could post several files throughout the day or none. When the vendor puts a new file in the directory, we want a process to run which will load the file into the database.

In order to process this type of scenario, you would actually need two distinct processes which might seem confusing at first.

  1. A daemon application engine that runs “continuously” in the background looking for the presence of a new file
    1. If the file (or any condition you code) is not found, then the process exits without doing anything.
    2. If the file (or any condition you code) is found, then this daemon process schedules a run of the secondary process that does the actual work.
  2. The secondary processes runs to process the file and update the database.
  • Why do we need two processes?
  • Why can’t I just put all the logic in the daemon program and have it run continuously?

These are good questions. The answer is simple. You want the daemon process that looks for the presence of a condition (a new file in our example) to run quickly and complete before the next heartbeat interval. You just want the daemon to run to determine “does condition x exist?” If the condition exists, we need to tell someone to go do some more work. That someone is another process.

Here is the pseudo code for the daemon

  • Does a new file exist?

That is all the logic that should be in the daemon application engine.