Message Priority Example Flow Chart

Message Priority Example Flow Chart

This example displays the behavior of Message Priorities. Message priorities allow messages to be prioritized and published depending on the priority rank they receive. If multiple messages are sent into a single publisher with different message priorities, the publisher will organize and publish each message depending upon which message holds the highest (1) priority.

For this example, a sender and receiver flow chart is used. The sender flow chart sends four separate messages in parallel to the same publisher. The receiver flow chart uses a Message Trigger to retrieve the messages from the publisher. No matter what order the messages are sent to the publisher via the sender flow chart, the publisher will organize them according to message priority.

Running this Example from the XML File

If you wish to run this example using an existing flow chart, create a new flow chart and select the “Import one flow chart from XML file:” check box. Then click the browse folder icon to browse for the “.ffc” file to import. Select the flow chart located in the same directory as this example and click “Open” then click the OK button. See Figure 1 below.

Figure 1: Importing a Flux Flow Chart

Getting Started

To get started, run the Flux Designer. You can start the Designer by clicking the blue highlighted hyperlink located directly above Figure 2 below.

Figure 2: Flux Designer Logo

Once you have the Flux Designer running, open the project that is located within the same directory as this example resides in, “/examples/end_users/message_priority”. To open the project, click the, open project icon, browse to the previously mentioned directory, open the “fluxproject.fpr” file.

Next, make a new flow chart, by either going to the “file” pull down menu at the top left of the screen and selecting “New". Select the “New Flow Chart” option and click OK .

Figure 3: "New" Options

Name the flow chart “Receiver” and click OK .

Follow the above instructions again to make a second flow chart in this project. Name the second new flow chart “Sender”.

Creating Actions

Next, create the actions used in the flow chart. Locate the actions and triggers needed using the “Action” and “Trigger” tabs to the left of the drawing canvas as shown in Figure 4 below. Drag the actions listed below in the bulleted list into your drawing canvas and arrange them according to Figure 6 displayed below.

Figure 4: "Action" and "Trigger" Tabs

The bulleted list below gives you the following information to help find the actions/triggers inside the Action and Trigger pane inside the Designer: The name of the action or trigger you need, the category that the action or trigger is located under, and how many instances are needed for this example. Each flow chart is separately listed.

Flow Chart: Sender

“Action” Tab:

· Action Name: “Console Action”, Category: “Core”, Quantity: 5

Figure 5: Sender Flow Chart Action's Layout

Flow Chart: Receiver

 “Trigger” Tab:

· Trigger Name: “Message Trigger”, Category: “Core” or “Messaging”, Quantity: 1

“Action” Tab:

· Action Name: “Console Action”, Category: “Core”, Quantity: 1

Figure 6: Receiver Flow Chart Action’s Layout

Setting up Flows

Next create flows from each action and trigger. Use Figure 7 and Figure 8 below as a guide to set up the flows for your flow chart. Follow the list of instructions below to create these flows.

1. Click the blank white space within your drawing canvas.

2. Click and hold on the action you wish to draw the flow from.

  1. Drag your cursor to the action you wish to draw the flow to and release.

Figure 7: Sender Flow Chart Layout

Figure 8: Receiver Flow Chart Layout

Renaming Actions

Next, give the actions more descriptive names. Giving actions specific names will help you from getting confused which actions you are dealing with in this example. Follow the steps below to edit an action’s name.

To edit an actions name:

  1. Right-Click on the action whose name you wish to edit. The menu shown below in Figure 9 will appear.

Figure 9: Editing the Action Name

  1. Click the “Edit action name” option on the drop down menu.
  2. Type in the name you wish to give the action.

Action Names

Use the bulleted list below as a reference to rename your actions.

Flow Chart: Sender

· “Console Action” to “Start”.

· “Console Action 2” to “Sender 1”.

· “Console Action 3” to “Sender 2”.

· “Console Action 4” to “Sender 3”.

· “Console Action 5” to “Sender 4”.

Once the actions are renamed, the flow chart will look similar to Figure 10 shown below.

Figure 10: Renamed Actions for the Sender Flow Chart

Flow Chart Receiver

· “Message Trigger” to “Receiver”.

· “Console Action” to “Finished”.

Once the actions are renamed, the flow chart will look similar to Figure 11 shown below.

Figure 11: Renamed Actions for the Receiver Flow Chart

Editing Flow Charts

Sender Flow Chart

Use the “Sender” flow chart and follow the steps below to edit actions and properties within the flow chart.

Console Actions

The console actions in this flow chart are used to inform the user of the flow chart’s progress by displaying messages on the engine’s console. To start editing these console action’s messages, click the “Start” console action. The “Start” console action’s “Action Properties” panel will appear to the right of the designer. Click the “Message” field and a text edit button will appear to the right of the field. Your “Action Properties” panel will look similar to Figure 12 below.

Figure 12: "Start" Console Action's Action Properties Panel

Click the text edit button within the “Message” field and an editor window will appear similar to Figure 13 below.

Figure 13: Console Action's Message Editor

Within the message editor type “Sender flow chart has begun execution..........” with two return lines. The return lines will make the info easier to read off of the console once the flow chart is run. Once the message is typed into the message editor, click the OK button.

Repeat the above procedure for all the remaining console actions within the Sender flow chart. Use the following key to add messages.

*Sender 1: “*Sender 1 published message….”

*Sender 2: “*Sender 2 published message….”

*Sender 3: “*Sender 3 published message….”

*Sender 4: “*Sender 4 published message….”

These messages will allow you to know which action executed and in which order.

Creating Message Checkpoints

Checkpoints assigned to a flow allow a message to be sent from a flow chart once that flow has been activated. To set up a checkpoint from the “Start” console action to the “Sender 1” console action, right click on the flow connecting these console actions. Select the “Edit Checkpoint” option in the menu that appears. Use Figure 14 below as a guide. 

Figure 14: Creating a Checkpoint in the Sender Flow Chart

Once the “Edit Checkpoint” window appears, type “POST MASTER” into the “Publisher Name” field. This directs the checkpoint to use the “POST MASTER” publisher, which we will create later in this example, to publish its message.

Next, type into the “Message Priority” field the number “1” signifying that should there be multiple messages sent to the publisher, this message will be the first to be published. Once the “Message Priority” field is set, a new message property called “PRIORITY” will appear in the “Message Properties” box with a value of 1.

Inside the “Message Body” field, click the "Add" button to add a new message body. Edit the “Name” field to read “BODY”. Keep the “Type” as a “String” then click OK. Edit the new message body field to read “From Sender 1”. Use Figure 15 below as a reference.

Figure 15: Creating a Checkpoint

Once you have edited all the necessary fields for the checkpoint, click the OK button to save the changes and return to the Designer’s main screen.

Next, create a checkpoint for the flows of the other three console actions from the “Start” action to “Sender” 2, 3, and 4. Create the checkpoints in the same manner as the first, varying the “Message Priority” and “Message Body” fields. Use the following list to set these fields to the appropriate values.

Action Name: Sender 2

Ø Message Priority: 2

Ø Message Body: From Sender 2

Action Name: Sender 3

Ø Message Priority: 3

Ø Message Body: From Sender 3

Action Name: Sender 4

Ø Message Priority: 4

Ø Message Body: From Sender 4

Once the checkpoints for each flow have been created, the “Sender” flow chart is complete.


Use the “Receiver” flow chart and follow the steps below to edit actions and properties within the flow chart.

Message Trigger

Within the “Receiver” flow chart, the message trigger “Receiver” must watch for published messages from the “POST MASTER” publisher. Once a message is published from that publisher, the message trigger will fire. To make the “Receiver” message trigger listen to the “POST MASTER” publisher, highlight the message trigger by clicking the trigger within the drawing canvas. The “Action Properties” panel for that trigger will appear to the right of the designer. Select the “Publisher” field within the “Action Properties” panel. Double click the text field to the right of the “Publisher” label to make the field editable. Type “POST MASTER” inside the field.

Console Action

The console action “Finished” within the “Receiver” flow chart serves as a benchmark to let you know when a message has arrived and from which action it originates from. To create this functionality for the console action configure the “Message” property of the “Finished” console action, as you did with the “Sender” flow chart’s console actions, to read “Message Processed” as shown below in Figure 16.

Figure 16: Console Action Message Editor

Next, edit the console action’s “Prescript” field to retrieve the body of each message received by the message trigger. By retrieving the body of each message you will be able to distinguish from which action the message was sent by. Edit the “Prescript” field by following the steps below.

  1. Bring up the console action’s “Action Properties” panel.
  2. Click the “Prescript” field and then the  button that appears to the right of the field.
  3. Within the “Prescript” editor that appears, input the following code:
import flux.messaging.MessageTrigger.Message_Res;
      Message_Res data = (Message_Res) flowContext.getLastResult();
      Map body = data.messageData;           
      Collection values = body.values();
      Iterator iter = values.iterator();
      while(iter.hasNext()) {
            print("Body: " +;

4. Click the OK button to return to the drawing canvas.

The above script retrieves the returned result of the previous action and prints the data to the console. In this case the message trigger’s data is retrieved by the console action and the body of the message is printed to the console. Once these steps are complete, both the “Receiver” and the “Sender” flow charts are complete.

Creating a Publisher through the Operations Console

Starting the Operations Console

  1. Execute the start-unsecured-flux-engine script from the Flux installation directory.
  2. Launch the Flux Web Application by running the start-opsconsole script from the Flux installation directory or by deploying flux.war in an servlet container.
  3. Browse to http://localhost:7186/. If flux.war is deployed in a servlet container, modify the URL as appropriate.
  4. You will arrive at the Flux Engines page of the Operations Console. This page displays a list of running Flux engines and the status of each. If the engine you created in step 1 does not appear on this page, perform the following steps:
    1. Click the "Sign In" link, located just above the engines list on the right-hand side.
    2. Enter admin for the security key.
    3. Click the "Add New Engine" button when it appears.
    4. Enter your engine's information, then click "Add To List".
  5. Click the name of the engine to access it.

After logging in, you will arrive at the Flux Operations Console.

Creating a Publisher

To create a publisher, select the “Messaging” tab towards the top of the Operations Console. The page represented in Figure 17 below will appear.

Figure 17: Creating New Publisher

Select the “New Publisher” button within the messaging page. The page represented below in Figure 18 will be loaded.

Figure 18: New Publisher Editor

In the “Name” field type “post master”. Once finished, click the “Create Publisher” button. Use Figure 19 below as a guide.

Figure 19: Create the "POST MASTER" Publisher

Associating a Flux Engine with the Project

Since a Flux engine is already running, move your cursor over the “Flux Engines” tab located at the left of the screen.

Click the "Add" button at the top of the “Flux Engines” tab and the window shown in Figure 20 below will appear.

Figure 20: Job Scheduler Engine Setup

Click on the “Advanced” tab at the top of the “Flux remote engine” window and click .

You should be back at the Flux main screen. Look at the “Flux Engines” tab again. The engine you just started should look like Figure 21, shown below.

Figure 21: Indicator for running Engine

Running the Flow Chart

Next, export both flow chart to the engine. Start by exporting the “Receiver” flow chart. Do this step by clicking the "Export to remote engine" icon at the top right of the Flux main screen. You may also export a job by clicking on the “Export” menu at the top of the screen and selecting “Export to remote job scheduler engine”. This menu is represented by Figure 22 below.

Figure 22: Export Menu

Click OK in the window represented by Figure 23 below.

Figure 23: Export to Engine

A confirmation window will appear if the flow chart was successfully exported. Click the OK button on the confirmation message. If there is an error message, look over this example carefully, and correct any mistakes made.

Export the “Sender” flow chart in the same manner.

Once both the “Receiver” and “Sender” flow charts have been successfully exported, locate the console on which your Flux engine is currently running. The results of the flow charts will look similar to the results shown below in Figure 24.

Figure 24: Results of the "Sender" and "Receiver" Flow Charts

Since the messages were prioritized, it does not matter in what order they are sent. The publisher will organize them accordingly.

Once this example is completed, shut down the engine by running the shut-down-unsecured-flux-engine script from the Flux installation directory.

Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.