Creating New User & Broadway Jobs

Jobs are defined in the Fabric Studio and can be saved to a project file and be deployed to the Fabric Server. A Job can be a Java function or a simple command.

How Do I Create a New User Job using Java code?

Step 1

Go to the Project Tree > LU > Java > Category and right click New Function to display the Function Editor window.

Step 2

Write the User Job function either from:

  • the Function Editor window

    or
    
  • the IntelliJ IDE.

//writing into a file;

while (test<5 && !isAborted()){
    test=test+1;
    sleep(10000);
    inSecTime=test*10; // value returned by user job function
    FileWriter myWriter = new FileWriter("job_test4.txt",true);
    myWriter.write("Test Number: "+ test +"::->" + 10*test + " seconds have passed since ...");
    myWriter.close();
    }

Step 3

Set the Function Type to the User Job value in the right panel. Once the job is triggered, the following Java user code writes a line into a new file job_test.txt every second until the counter test reaches the value 5. The output file is located in the Fabric Home directory.

Note that the loop control parameter (variable test) is defined as an input parameter of the User Job function, and that a second variable inSecTime is also defined as an output parameter. As such, its value is recorded in the argument field of the k2_jobs table in the k2system keyspace.

Name and save the function.

Step 4

Go to the Project Tree > your LU > Jobs.

Jobs can be created also as References regardless of the specific LU. In the Job table, enter the values pertaining to the Job.

Method The name of the User Job Function (defined in Step 4) associated with the Job.
Unique Job Name The unique name of the Job service used for all manual or system operations executed on this job.
Execution Mode Can be set either automatically or manually depending on whether the Job service is started from the Command Line or job will start automatically upon deployment.
Active When checked, the Job is run and deployed.
Schedule Type

There are three schedule modes:

  • CRON, runs the Job according to the frequency described in the Cron description tab.
    For example, set the execution to: 30 0/2 8-18 5 3 ? 2021 at 30 seconds past the minute (30), every 2 minutes (0/2), between 08:00 and 18:59 (8-18), on day 5 of the month (5), only in March (3), only in year 2021 (2021).

  • TimeStamp, schedules a Job to run once on a given date and time. For example, set the execution to 2022-08-20 10:32:12.

  • Time Interval, schedules the Job to run at the frequency specified in the Execute Every field: For example, set the execution to: 10.11:22:33.  . The job runs every 10 days, 11 hours, 22 minutes, 33 seconds. If the time interval is set to 00:00:00, the job runs once automatically.

    It is important to note that if a scheduled job is started manually (before its scheduled occurance) then its next scheduled occurance will still start on time, unless the previous manual occurance of the job is still running.

Affinity

The details of the node assigned to the job. Affinity can be set using either one of the following options:

  • IP address of a Fabric node.
  • Data Center (DC) Name.
  • Node identifier, a logical identifier of Fabric node or a group of several Fabric nodes.

Example: AFFINITY=’DC1’, ’10.21.1.121’

Input parameters

Defines where the values of the input parameters are initialized. In this case the variable *test* is set to 0.

(The output parameter value is recorded in the argument field of the k2_jobs table in the k2system keyspace.)

 

Step 5

Right click the LU in the Project Tree, deploy and then search for the file in the Fabric Home directory.

How Do I Create a Broadway Job using the BroadwayJob Actor ?

The BroadwayJob actor provides the ability to trigger a Fabric Job that will in turn execute another Broadway flow once or multiple times depending upon the configuration of the job.

To use this capability, simply select the actor from the Add Actors To Stage menu in the Broadway Flow panel, as illustrated below:

The following parameters are to be filled in the properties tab:

  • Name: name of the flow to be triggered by this actor.
  • UID: unique ID for this job.

Note that both name and UID can either be chosen by the user, attributed automatically by Fabric, or parsed from a previous actor.

  • Schedule: the execution frequency of the job, which can be either one of the following:

    • Immediate
    • Interval
    • Date/Time
    • CRON schedule
  • Affinity: this sets which node/DC name IP address is to be used to run the Broadway job.

  • Params: This refers to the arguments that can be parsed to the Broadway flow. For example, multiple parameters can be parsed as a key/value object from an external link.

Please refer to this section in order to learn how to setup the schedule type and the affinity appropriately.

Previous

Creating New User & Broadway Jobs

Jobs are defined in the Fabric Studio and can be saved to a project file and be deployed to the Fabric Server. A Job can be a Java function or a simple command.

How Do I Create a New User Job using Java code?

Step 1

Go to the Project Tree > LU > Java > Category and right click New Function to display the Function Editor window.

Step 2

Write the User Job function either from:

  • the Function Editor window

    or
    
  • the IntelliJ IDE.

//writing into a file;

while (test<5 && !isAborted()){
    test=test+1;
    sleep(10000);
    inSecTime=test*10; // value returned by user job function
    FileWriter myWriter = new FileWriter("job_test4.txt",true);
    myWriter.write("Test Number: "+ test +"::->" + 10*test + " seconds have passed since ...");
    myWriter.close();
    }

Step 3

Set the Function Type to the User Job value in the right panel. Once the job is triggered, the following Java user code writes a line into a new file job_test.txt every second until the counter test reaches the value 5. The output file is located in the Fabric Home directory.

Note that the loop control parameter (variable test) is defined as an input parameter of the User Job function, and that a second variable inSecTime is also defined as an output parameter. As such, its value is recorded in the argument field of the k2_jobs table in the k2system keyspace.

Name and save the function.

Step 4

Go to the Project Tree > your LU > Jobs.

Jobs can be created also as References regardless of the specific LU. In the Job table, enter the values pertaining to the Job.

Method The name of the User Job Function (defined in Step 4) associated with the Job.
Unique Job Name The unique name of the Job service used for all manual or system operations executed on this job.
Execution Mode Can be set either automatically or manually depending on whether the Job service is started from the Command Line or job will start automatically upon deployment.
Active When checked, the Job is run and deployed.
Schedule Type

There are three schedule modes:

  • CRON, runs the Job according to the frequency described in the Cron description tab.
    For example, set the execution to: 30 0/2 8-18 5 3 ? 2021 at 30 seconds past the minute (30), every 2 minutes (0/2), between 08:00 and 18:59 (8-18), on day 5 of the month (5), only in March (3), only in year 2021 (2021).

  • TimeStamp, schedules a Job to run once on a given date and time. For example, set the execution to 2022-08-20 10:32:12.

  • Time Interval, schedules the Job to run at the frequency specified in the Execute Every field: For example, set the execution to: 10.11:22:33.  . The job runs every 10 days, 11 hours, 22 minutes, 33 seconds. If the time interval is set to 00:00:00, the job runs once automatically.

    It is important to note that if a scheduled job is started manually (before its scheduled occurance) then its next scheduled occurance will still start on time, unless the previous manual occurance of the job is still running.

Affinity

The details of the node assigned to the job. Affinity can be set using either one of the following options:

  • IP address of a Fabric node.
  • Data Center (DC) Name.
  • Node identifier, a logical identifier of Fabric node or a group of several Fabric nodes.

Example: AFFINITY=’DC1’, ’10.21.1.121’

Input parameters

Defines where the values of the input parameters are initialized. In this case the variable *test* is set to 0.

(The output parameter value is recorded in the argument field of the k2_jobs table in the k2system keyspace.)

 

Step 5

Right click the LU in the Project Tree, deploy and then search for the file in the Fabric Home directory.

How Do I Create a Broadway Job using the BroadwayJob Actor ?

The BroadwayJob actor provides the ability to trigger a Fabric Job that will in turn execute another Broadway flow once or multiple times depending upon the configuration of the job.

To use this capability, simply select the actor from the Add Actors To Stage menu in the Broadway Flow panel, as illustrated below:

The following parameters are to be filled in the properties tab:

  • Name: name of the flow to be triggered by this actor.
  • UID: unique ID for this job.

Note that both name and UID can either be chosen by the user, attributed automatically by Fabric, or parsed from a previous actor.

  • Schedule: the execution frequency of the job, which can be either one of the following:

    • Immediate
    • Interval
    • Date/Time
    • CRON schedule
  • Affinity: this sets which node/DC name IP address is to be used to run the Broadway job.

  • Params: This refers to the arguments that can be parsed to the Broadway flow. For example, multiple parameters can be parsed as a key/value object from an external link.

Please refer to this section in order to learn how to setup the schedule type and the affinity appropriately.

Previous