# Step 14: Designing a Message Path for Your Business Process

In this step, you create a message path on your business process that specifies the logic to handle a callback from the channel to which the ValidateOrder service posts a message.

In this case, you associate the Message path you create with the Start node in your business process. It is also possible to associate Message paths with individual nodes or groups of nodes. For the case in which a Message path is associated with the Start node, the logic defined within the path applies to the entire business process in the event a message is received on this path. (The same is true for Exception paths and Timeout paths created on business process Start nodes.) The logic defined for paths associated with individual nodes or groups of nodes applies to those individual or groups of nodes. To learn more about Message, Exception, and Timeout paths for business processes, see Related Topics.

This step includes the following tasks:

- To Create a Message Path on Your Business Process That Handles Messages Routed via a Channel to Which Your Process is Subscribed
- To Design a Node to Receive the Message Event From the StopQuote Channel
- To Specify the Behavior of Your Business Process in the Event that the Message Path is Triggered
- To Design a Node to Send a Message to Clients in the Event the Business Process Receives a StopQuote Message From the StopQuote Channel

To Create a Message Path on Your Business Process That Handles Messages Routed via a Channel to Which Your Process is Subscribed

In this step, you learn how to create a message path on your business process that handles the following tasks:

- Receives the message event from the StopQuote Message Broker channel to which your process is subscribed.
- Specifies the run-time behavior of the process in the event the message path is executed: if a message is received from the StopQuote channel, the process sends a message to the client from which the Request for Quote originated, and terminates the Request for Quote business process.

Message paths can be associated with individual nodes or groups of nodes that contain a blocking element, or with the business process (global). In this case, you design a global message path for the business process by specifying the message path at the Start node.

To Design a Node to Receive the Message Event From the StopQuote Channel

1. Ensure that the RequestQuote business process is displayed in the Design View.
2. Right-click the Start node, then choose Add Message Path from the drop-down menu.

A path, which contains a placeholder for the event that invokes the path at run time, is created to the right of the Start node in the Design View:

Note: The Message Broker Subscription control you created in Step 13 does not define callback methods for you. You design a Control Receive node on this message path to define a custom callback that specifies how the business process expects to receive the event messages from the StopQuote channel to which it is subscribed.

3. Double-click the Starting Event node on the message path to display the types of nodes you can choose for this path.
4. Choose A Control Receive, then click the X in the top right-hand corner of the node builder.

A Control Receive node is added to the OnMessage path. This node specifies that this path waits to receive a message from a control.

5. On the Data Palette, click the following method in the mbSubValidate control:

    void onMessage(String message)

6. Drag and drop the method onto the message path (OnMessage), placing it on the Control Receive node.

The Control Receive node in the OnMessage path changes to reflect the binding of the Subscription control method: the node is named onMessage and the Start node icon reflects a Message Broker Subscription control. Your message path should resemble that displayed in the following figure:

7. Double-click the onMessage node. The node builder opens on the General Settings tab. The mbSubValidate control and its void onMessage (String message) method are already selected.
8. Click Receive Data to open the second tab in the node builder, in which you can assign a variable to which the message that is received from the StopQuote channel is stored.

The Control Returns field is populated with the data type and the name of the parameter expected by the control: String message.

9. In the Select variables to assign field, click the arrow to display the variables in your project, then select Create new variable.... The Create Variable dialog box is displayed.
10. In the Variable Name field, enter stopQuote.
11. In the Select Variable Type pane, select String in the list of Java Types. The Variable type field is populated with java.lang.String.
12. Click OK. The stopQuote variable is created and is displayed in the Receive Data tab (and on the Data Palette Variables tab).

This completes the assignment of the message from the StopQuote Message Broker channel to the stopQuote variable.

13. To close the onMessage node builder, click the X in the top right-hand corner.

This step completes the design of the callback handler that handles a message event on the StopQuote channel to which your RequestQuote business process is subscribed.

To Design a Node to Send a Message to Clients in the Event the Business Process Receives a StopQuote Message From the StopQuote Channel

1. Ensure that your RequestQuote business process open in the Design View.
2. Click Client Response in the Palette, then drag and drop the node onto the business process, placing it on the message path, immediately after the onMessage subscription node. The Design View is updated to contain the Client Response node.

3. Change the name of the node from Client Response to Deny Quote.
4. Double-click the Deny Quote node to open its node builder.
5. In the General Settings tab, change the default name in the Method Name field to denyQuote.
6. Click Add to display the panel of data types.

Note: In a preceding step, you created a variable of type String to hold the message received from the ValidateOrder service, via the StopQuote channel. This is the message your RequestQuote business process sends to clients in the event that the Request for Quote is invalid. Therefore we are concerned with String Java Types at this node.

7. Select Java on the panel of data types, then in the list of Java Types, select String. The Type field is populated with java.lang.String.
8. In the Name field, replace the default x0 by entering stopQuote and click OK.
9. Click the Send Data tab to open the tab that allows you to assign the variable that holds the data your business process sends to clients.

The Client Expects field is populated with the data type and parameter name you specified on the General Settings tab: String stopQuote.

10. Under Select variables to assign, select stopQuote (String).

11. To close the Client Response node builder, click the X in the top right-hand corner.

In the Design View, note that by completing the tasks in the node builder, the completeness icon associated with the Send Quote node changed from to indicating that the design of the node is complete.

12. From the Workshop menu, select File —> Save.

To Specify the Behavior of Your Business Process in the Event that the Message Path is Triggered

In this step you learn how to specify the run-time behavior of your business process in the event this message path is triggered. To do so, you use the Property Editor to set the after execute property for your message path.

1. In Design View, click the OnMessage path icon. The Property Editor displays properties for the OnMessage path.

Note: If the Property Editor is not visible in WebLogic Workshop, select View —> Property Editor from the menu bar.

2. Verify the following properties for the OnMessage path:

- name—Displays the name of the message path: OnMessage. Click on this property if you want to enter a new name for the path.
- notes—You can click ... in the notes field to invoke a text editor in which you can add text. For example, you can use it to document something about this node.
- after execute—Specifies the behavior of the business process when this message node is activated at run time. skip is specified by default.

Valid options for this property include skip and resume, described here for heuristic purposes. In our scenario, you should not change the default specification.

skip—Specifies that after execution of the message path, the process engine skips the node or group with which the message path is associated. That is, the process engine resumes execution of the process at the node following the node or group for which the message path is defined. In the special case of a global message path—one defined for the business process on the Start node—the process is terminated after execution of the message path.

resume—Specifies that after execution of the message path, the process engine resumes execution of the business process at the node that was executing when the message was received. That is, the process state returns to what it was before the message path executed and the On Message port is still active.

- retry count—Specifies how many times the process engine retries to execute the nodes contained in the Message path after the first attempt to execute them and before the after execute path is taken. Zero is specified by default.

This step completes the design of the message path on your RequestQuote business process.

By completing this section, you created the logic that allows your RequestQuote business process to publish the Request for Quote message it receives from clients to a Message Broker channel. (A validation service is subscribed to that channel). You also created a dynamic subscription to another Message Broker channel to allow your RequestQuote business process to receive messages published by the validation service.

To run the business process you created by following the steps in Part IV of this tutorial, proceed to Step 15: Run and Test the Request Quote Business Process With the Quote Validation Service.

Related Topics

To learn about designing Message paths, Exception paths, and Timeout paths for your business process, see the following topics in the Guide to Building Business Processes:
Handling Exceptions
Adding Message Paths
Adding Timeout Paths