# How Do I: Subscribe to Message Broker Channels?

You design a subscription to a Message Broker channel in one of two ways in your business processes: you create an instance of a Message Broker Subscription control and design the subscription using it, or for the special case of a process that is started as a result of a subscription to a Message Broker channel, you design the subscription on the process' Start node.

To learn how to design the Start-node subscriptions, see Subscription Start (Asynchronous) and Subscription Start (Synchronous).

This section describes how to create a Message Broker Subscription control in your project, then bind a method from the control to a node in your business process.

Note: In WebLogic Integration, subscriptions to Message Broker channels defined at a Start node are referred to as static subscriptions, and subscriptions defined using a Message Broker Subscription control are referred to as dynamic subscriptions. See "Note about Static and Dynamic Subscriptions" in @jpd:mb-static-subscription Annotation.

To Subscribe to a Message Broker Channel Using a Subscription Control

1. In the Application tab, double-click the applicable business process to ensure that it is displayed in the Design View.
2. On the Data Palette Controls tab, click Add —> Integration Controls —> MB Subscription.

The Insert Control dialog box is displayed.

3. In Step 1, enter the variable name for this control.
4. In Step 2, do one of the following:

1. To use an existing MB Subscription control, select Use a MB Subscription control already defined by a JCX file, then enter the name of a JCX file or use Browse to select the JCX file.
2. To create an existing MB Subscription control, select Create a new MB Subscription control to use, then, in the New JCX name field, enter the name for the new JCX file.

5. In Step 3, select the applicable channel from the channel-name field. This specifies the channel to which your business process subscribes (and the channel to which the Validation service publishes messages when it determines that an incoming message is invalid).

Note: The message-type field is populated with the data type of the message that is published to the selected channel. To learn how the channel is defined, see Understanding the Message Broker Channels in Your Tutorial Application.

6. If you intend to use filters on the channel, select This subscription will be filtered.
7. Click Create.

The Insert Control dialog box closes and the new JCX file is created and displayed in the Application tab. The instance of the Message Broker Subscription control you created is displayed in the Data Palette.

8. In the Data Palette, select the subscribe method in the control:

    void subscribe()

9. Drag-and-drop the method onto the business process in the Design View.

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, unless you selected to use a filter. If so, proceed to the To Specify a Filter Value for Your Channel section.

Note: When you create your control, a callback method is created for you (void OnMessage(message)). You can drag-and-drop this method from the Data Palette onto your business process. This creates a Control Receive node that you can configure to handle your callback. For an example, see Step 14: Designing a Message Path for Your Business Process in the Tutorial: Building Your First Business Process.

To Specify a Filter Value for Your Channel

If you selected the This subscription will be filtered check box in step 5. in the above procedure, you must enter a filter value for your subscribeWithFilterValue(value) before your filter will work properly.

1. In the Application tab, double-click the subscription JCX file that you created earlier.

Note: If the Application tab is not visible, select View —> Application.

The JCX file is displayed in Design View.

2. Click the arrow pointing to your subscribeWithFilterValue method, as shown in the following figure.

3. In the Property Editor, beneath the mb-subscription-method property, in the filter-value-match field, click .

The Property Text Editor window opens.

4. In the Property Text Editor, replace {value} with the value that you want your subscription control to filter on.
5. Click OK.

The Property Text Editor closes and the valued you entered will be used as the filter value at run time.

Related Topics

How Do I: Create Message Broker Channels?

How Do I: Publish to Message Broker Channels?

Message Broker Subscription Control

Subscription Start (Asynchronous)

Subscription Start (Synchronous)

Dead Letter Channels

@jpd:mb-static-subscription Annotation