Tutorial: Building Your First Business Process

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 13: Publish and Subscribe to Message Broker Channels

To design the Message Broker functionality described in Understanding the Validation Service Scenario, you create nodes in your RequestQuote business process: one that publishes to the ValidateOrder Message Broker channel and one that subscribes to the StopQuote Message Broker channel. Subsequently, you create a message path on your business process. On the message path, you create the logic to handle the callback from the channel (StopQuote) to which the ValidateOrder service posts a message. That logic specifies that the RequestQuote business process terminates after it receives a callback from the channel to which it is subscribed.

This step includes the following tasks:

To Publish the Request for Quote Message to a Message Broker Channel

You must first create a Message Broker Publish control in your project, then bind a method from the control to a node in your business process. To do so, complete the following steps:

  1. In the Package Explorer pane, double-click RequestQuote.java to ensure that it is displayed in the Design View.
  2. If the Data Palette is not visible in BEA Workshop, click WindowsArrow symbolShow ViewArrow symbolData Palette from the menu bar.
  3. In the Data Palette, on the Controls folder, click Arrow symboland select Integration ControlsArrow symbolMB Publish. The Insert Control dialog box is displayed.


  4. Enter mbPubValidate in the field name for this control, and click Next.
  5. In the Create Control wizard page, enter MBPubValidate in the Name field, and click Next.
  6. In the Insert Control - MB Publish dialog box, click the down arrow associated with the Channel name field to display the channels available in your application:
  7. /TutorialPrefix/Tutorial/ValidateOrder
    /TutorialPrefix/Tutorial/StopQuote
    Note: The following channels are also available: /deadletter/xml, /deadletter/string, /deadletter/rawData, /WorklistEvent. To learn about using dead letter channels in your applications.
  8. Select /TutorialPrefix/Tutorial/ValidateOrder. This specifies the channel to which your business process publishes the Request for Quote messages it receives from clients.
  9. The message type field is populated with the data type of the message that is published to the ValidateOrder channel: org.example.request.QuoteRequestDocument.

    Note: If the channels are not available for you to select in the Channel name field, you must build your Utility project. To do so, first click Cancel in the Insert Control dialog box to close it. Then right-click on the Utility Project folder in the Package Explorer pane and choose Build Project from the drop-down menu. When the project finishes building, click , and select Integration ControlsArrow symbolMB Publish on the Data Palette Controls tab to open the Insert Control dialog box. Repeat steps 4 through 6, as described above. The channels are now available in the channel-name field. (The channel files that define Message Broker channels in your application are located in a project, and must be built in that project for them to be available in your application. To learn how the ValidateOrder channel is defined, see Understanding the Message Broker Channels in Your Tutorial Application.
  10. Click Finish. An instance of the MB Publish control in your project is created, the Insert Control dialog box is closed, and the MBPubValidate.java file is created and is visible in the Package Explorer pane. The instance of the mbPubValidate control you created is displayed in the Data Palette:


  11. In the Data Palette, click the following method in the mbPubValidate control:
  12. void publish(QuoteRequestDocument value)
  13. Drag and drop the method onto the RequestQuote business process placing it immediately after the Client Requests Quote Start node.


  14. A Control Send node is created. By default, the node is named publish.

  15. Double-click the publish node. The node builder opens on the General Settings tab. The mbPubValidate control and the void publish (QuoteRequestDocument value) method are already selected.
  16. Click Send Data to open the second tab in the node builder, in which you can specify the message to be published to the ValidateOrder Message Broker channel.
  17. The Control Expects field is populated with the data type of the parameter expected by the control: QuoteRequestDocument.

  18. In the Select variables to assign field, click the arrow to display the variables in your project, then select requestXML (QuoteRequest).
  19. Note: Recall that when you designed the Start node for your business process at the beginning of the tutorial, you assigned the Request for Quote messages from clients to the requestXML variable.
  20. To close the node builder, click Close.
To Subscribe to a Message Broker Channel to Receive Messages from a Validation Service

You must create a Message Broker Subscription control in your project, then bind a method from the control to a node in your business process. Using the Message Broker Subscription control, your process subscribes to a channel on which Validation services can publish messages if the Request for Quote from the client is invalid. In the tutorial scenario, a ValidateOrder service determines that a Request for Quote is invalid if the number of widgets requested by a client is greater than 400. Complete the following steps:

  1. Ensure that the RequestQuote business process is displayed in the Design view.
  2. On the Data Palette Controls tab, click , and select Integration ControlsArrow symbolMB Subscription. The Insert Control dialog box is displayed.


  3. In the Insert Control dialog box, enter mbSubValidate as the variable name for this control, and click Next.
  4. In the Create Control dialog box, enter MBSubValidate in the Name field, and click Next.
  5. In the next dialog box, for the channel name select /TutorialPrefix/Tutorial/StopQuote.
  6. This specifies the channel to which your business process subscribes. It is also the channel to which the ValidateOrder service publishes messages when it determines that a Request for Quote is invalid.

    Note: The message type field is populated with the data type of the message that is published to the StopQuote channel: java.lang.String. To learn how the StopQuote channel is defined, see Understanding the Message Broker Channels in Your Tutorial Application.
  7. Click Finish to create an instance of the MB Subscription control in your project.
  8. The Insert Control dialog box is closed and the MBSubValidate.java file is created and is visible in the Package Explorer pane. The instance of the mbSubValidate control you created is displayed in the Data Palette:



  9. In the Data Palette, click the following method in the mbSubValidate control:
  10. void subscribe()
  11. Drag and drop the method onto the RequestQuote business process in the Design View, placing it immediately after the publish node.


  12. A Control Send node is created. By default, the node is named subscribe. Note that the indicates that the specifications on this node are complete—no further work is required to design this node.

Note: Message Broker Subscription controls do not define callback methods for you. You must define a custom callback to specify how the business process expects to receive the event messages. To define the callback for your business process, proceed to Step 14: Designing a Message Path for Your Business Process.

This step completes the design of the nodes that specify how your RequestQuote process publishes and subscribes to Message Broker channels.

Related Topics

Understanding the Message Broker Channels in Your Tutorial Application

Message Broker Controls


  Back to Top       Previous  Next