How to Save Hourly Stock Prices to a Daily File
The example will show you how to create an hourly job to load stock prices from Google finance and save them to a daily file.
You should read about how to create a simple job before continuing with this.
You'll need to download a copy of the Data Pipeline framework to compile and run this job.
1. Create the job factory class
In the how to create a
simple job example, you created a class implementing
and registered it as a job in your project. This example will go a
step higher and implement a
The factory approach lets you return different instances of
depending on the situation. In this case the Runnable returned
will be a DataPipeline Job instance ― which also happens to implement
You can read about the details of this code in the Read a JSON Stream example. The important things to know are:
- The factory's
createJob()method is called each time the job is run.
- The factory uses the symbols and file parameters to build the job instance.
2. Create a project
The next step is to define your
Job parameters are expressions that get evaluated just before each job is run. See the Data Pipeline Expression Language page to understand which types of expressions and functions are supported. For now, just keep in mind:
- String values must be quoted with double or single quotes or they will be treated as variables.
- Slashes must be escaped the same as in Java string literals.
3. Deploy the project
- Compile and jar the job class you created in the first step
- Create a folder for your new project inside
<workspace-folder>/projects/. For example:
- Place your
project.xmlfile inside your new project folder.
- Create a
libfolder under your new project folder.
- Place your project's jar inside the new lib folder.
- Place the Data Pipeline jar (NorthConcepts-DataPipeline-4.1.0.jar) inside the new lib folder.