Child pages
  • Quick Start Guide

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update the QuickStart Page

...

  1. Start the Flux engine. You can easily start the engine by running the start-engine script, located in the Flux installation directory.

    If you have installed Flux on Windows using the .exe installer, the Flux engine should also be installed as a Windows service. You can use the Windows services control panel to easily start and stop the engine, as an alternative to using the start-engine script.
  2. Start the Operations Console. You can start the Console by running the start-opsconsole script from your Flux installation directory.

    Like the engine in step 1, the Operations Console may be installed as a Windows service if you have installed from the .exe. You can use the Windows services control panel to start and stop the Operations Console as well. 
  3. Open a web browser and navigate to the Operations Console by entering the URL http://<host>:7186, where <host> is the host name of the machine where you ran the start-opsconsole script (if your browser is running on the same server as that script, you can use _http://localhost:7186_).
  4. If this is your first time visiting the Operations Console, you will be greeted with the welcome screen (if the welcome message does not appear, skip to step 4). Click "Let's get started" to continue.

    Image Modified
  5. A sign in page will appear, prompting you for your user credentials. Use the default username and password "admin" to continue:

    Image Modified
  6. After signing in, you will arrive at the home page of the Operations Console. From this page, you can view workflows on the engine (if any are running) and access all of the components of the Operations Console.
    Image Removed
    Image Added

Designing and Running the Workflow

...

  1. Click the "Designer" tab in the Operations Console's navigation bar:
    Image Removed
    Image Added
  2. Notice the "Actions & Triggers" panel on the left-hand side of the screen. This panel contains all of the triggers and actions you can use to design your workflows. The triggers and actions are divided by functionality into several groups,

    In this case, we are interested in the timer trigger. Find the timer trigger in the "Core" section, then click and hold with the left mouse button and drag the trigger to the workspace. Release the mouse button to place the trigger.

  3. Repeat the process, but this time add a process action to the workflow. Your workflow should now look something like this:

  4. Select the connect tool by clicking the "Connect" icon in the Designer toolbar (this icon appears as two points connected by a line). This tool allows you to add flows between your actions and triggers, which allow you to express to Flux which triggers and actions should run and in what order. In other words, flows tell Flux what sequence your triggers and actions will run in.

    To add a flow from one trigger or action to another, just click and hold the mouse on the trigger or action you want to flow from, then drag the cursor to the trigger or action you want to flow to and release the mouse button. Once you've created the flow, it will automatically be selected on the page, and you can use the on-screen tools to visually move or reorganize the flow as needed (NOTE: in some browsers, the flows may appear to be unusually shaped or missing their directional arrow icon. If this occurs, just click "Save to Repository" in the lower right-hand corner of the screen, click the "Repository" tab in the console, select your workflow, and click "Edit". Your flows should now appear as normal on the screen).

    For this example, just add one flow from the timer trigger to the process action, then another flow back from the process action to the timer trigger. This will complete what is known in Flux as a "loop": a series of triggers and actions that run in a repeated sequence. In this case, the timer trigger will wait for a certain time to occur, flow into the process action (which will then execute), and finally flow back into the timer trigger to wait for the next scheduled date and time.

  5. Now that the actions and flows have been created, it's time to set up the action properties that will tell Flux when or how each trigger and action will run. First, double-click the Timer Trigger to bring up its "Action Properties" panel. Click "More Properties" to display the complete list of properties available.

    For this trigger, make sure that the "Start Action" property is selected. This property indicates that, when the workflow begins executing, this is the first trigger that should run. You can also give the action a more descriptive name by editing the "Name" property; in the screen shot below, the trigger has been renamed to "Monday through Friday".

  6. With the "Action Properties" panel still open, click the clock icon just to the right of the "Time Expression" property. This will launch the time expression editor, which you can use to configure when (and how often) the timer trigger will execute.

    You can use this editor to help design time expressions that are as complicated (or as simple) as you need. In this case, we'll just give the trigger an expression of *0 0 +30 8-12 * * mon-fri * * * **, which means "every 30 minutes, from 08:00 to 12:00, Monday through Friday". Once you've set up the time expression, click "Save" to save your changes, then "OK" to save the properties on the timer trigger.

  7. Double-click the process action to open its "Action Properties" window. You'll notice the process action shares several properties with the Timer Trigger, including the "Name" property, where you can give the action a more descriptive name. In this case, make sure that the "Start Action" property is not set, since we want the timer trigger to run first for this example.

    For this action, you will need to set the "Command" property, which tells Flux which command or process should launch when this action executes. For this example, we've chosen the command notepad.exe, which should be available by default on all Windows machines. If you're using a Unix system, or if you just want to try a different command, you'll need to change this to use whichever command you'd prefer instead.

    Warning

    The command your Process Action uses must be available from the system path in order for Flux to invoke it. If your command isn't available on the path, you'll need to provide the full path to the command (for example, C:\system32\notepad.exe). For more information on this, see Process Action.


    Once you've configured the action to run your command, click "OK" to save your changes.

  8. Your workflow is now configured and ready to run! If you'd like to save your changes now, click "Save to Repository" in the lower right-hand corner of the page. Otherwise, just click "Export to Engine" to begin running your workflow.



  9. If the workflow was exported into the Flux engine successfully, a confirmation message will appear, and the Designer will automatically change views to the Real-time Monitor, which you can use to easily track the process of this workflow.

...

Code Block
package doc.quick_start_guides.quick_start_job_scheduling.software_developers;

import flux.ActionListener;
import flux.Cron;
import flux.CronColumn;
import flux.Engine;
import flux.EngineHelper;
import flux.Factory;
import flux.FlowChart;
import flux.JavaAction;
import flux.KeyFlowContext;
import flux.TimerTrigger;

/**
 * Quick Start example for scheduling Java code for execution.
 */
public class JobScheduling {

//  Create a Flux factory, from which all other Flux objects are derived.
  Factory factory = Factory.makeInstance();

//  Create a fresh cron.
  Cron cron = EngineHelper.makeCron();
  public JobScheduling() throws Exception {

//    Create a workflow.
    FlowChart flowChart = EngineHelper.makeFlowChart("Workflow");

//    Create a timer trigger.
    TimerTrigger timer = flowChart.makeTimerTrigger("Timer");
    timer.setStartAction(true);

//    Fires every 10 seconds , every minute, every hour, Monday-Friday.
    cron.add(CronColumn.MILLISECOND, 0);
    cron.addAll(CronColumn.SECOND, 10);
    System.out.println("The Cron that is produced is " + "\"" + cron.toString() + "\"");

//    The created cron must be set here.
    timer.setTimeExpression(cron.toString());

//    Work week cron shown below. Fires every 15 minutes, 8-12 am, and 1-5 pm,
//    Monday-Friday.
//    cron.add(CronColumn.MILLISECOND, 0);
//    cron.add(CronColumn.SECOND, 0);
//    cron.addAll(CronColumn.MINUTE, 15);
//    cron.add(CronColumn.HOUR, 8,12);
//    cron.add(CronColumn.HOUR, 13,15);
//    cron.add(CronColumn.DAY_OF_WEEK, Cron.MONDAY, Cron.FRIDAY);
//    Create a Java Action to implement your Java code in Flux.
    JavaAction javaAction = flowChart.makeJavaAction("Java Action");
    javaAction.setListener(JavaCode.class);

//    Create flows from each action.
    timer.addFlow(javaAction);
    javaAction.addFlow(timer);

//    Create a Flux engine.
    Engine engine = factory.makeEngine();

//    Add the workflow into the engine to execute.
    engine.put(flowChart);

//    Start the engine.
    engine.start();

//    Wait for the user to press any key before the engine is disposed.
    System.in.read();
    System.out.println("The engine has been disposed.");
    engine.dispose();
  }

/**
*     Listener for the Java Action. Put your Java Class into this listener.
*/
  public static class JavaCode implements ActionListener {

    public Object actionFired(KeyFlowContext flowContext) throws Exception {
      System.out.println("Your Java Code Goes Here!");
      return null;
    }
  }

/**
*     A simple way to run this example.
*/
  public static void main(String[] args) throws Exception {
    new JobScheduling();
  }
}