Message Broker Publish Control

Two Message Broker controls are available from your business processes: Publish and Subscription. Your business process uses a Publish control to publish messages to Message Broker channels. You bind the Message Broker channel to the Publish control when you declare the control, but it can be overridden dynamically. You can add additional methods to your extension (subclass) of the Message Broker Publish control.

For information on how to add control instances to business processes, see Using Controls in Business Processes.

The following topics provide information about creating and using Message Broker Publish controls:

To Create an Instance of a Message Broker Publish Control

  1. Click Add on the Controls tab to display a list of controls that represent the resources with which your business process can interact.
  2. Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.

  3. Choose Integration Controls to display the list of controls used for integrating applications.
  4. Choose MB Publish. The Insert Control dialog box is displayed.
  5. In the Insert Control dialog box (Step 1), enter a name for the instance of this control. The name you enter must be a valid Java identifier.
  6. In the Insert Control dialog box (Step 2), select one of the following options:
  7. In the Insert Control dialog box (Step 3), specify the channel name as follows:
  8. Click Create to close the Insert Control dialog box.
  9. An instance of a MB Publish control is created in your project and displayed in the Controls tab. The following figure shows an example instance of a MB Publish control displayed in the Controls tab:

    image

JCX File for Your MB Publish Control

When you create a new MB Publish control, you create a new JCX file in your project. The following example JCX file is automatically created by the control wizard:

import com.bea.control.PublishControl; 
import com.bea.data.RawData; 
import com.bea.xml.XmlObject;  
/** 
 * Defines a new Publish control. 
 * 
 * @jc:mb-publish-control channel-name="/controls/channe1" 
 */  
public interface mbPublish extends PublishControl,
 com.bea.control.ControlExtension
    /** 
     * @jc:mb-publish-method message-body="{value}" 
     */ 
    void publish(String value); 
    /** 
     * @jc:mb-publish-method message-metadata="{metadata}" message-body="{value}" 
     */ 
    void publishWithMetadata(XmlObject metadata, String value); 
}   

Using Methods of the MB Publish Interface

This section describes the MB Publish control interface. Use the methods from within your application to publish to Message Broker channels.

MB Publish Control Interface

package com.bea.control;

import com.bea.wli.control.dynamicProperties.PublishControlPropertiesDocument;
import org.w3c.dom.Element;
import weblogic.jws.control.Control;

/**
 * Message Broker Publish control base interface 
 */ 
public interface PublishControl extends Control { 
    /**
     * Temporarily sets the message headers to use in the next publish operation
     * @param headers headers to set
     */ 
    void setOutputHeaders(Element[] headers); 
    /**
     * Sets the dynamic properties for the control
     * @param props the dynamic properties for the control
     */ 
     void setProperties(PublishControlPropertiesDocument props);
    /**
     * Sets the dynamic properties for the control
     * @return the current properties for the control
     */ 
     PublishControlPropertiesDocument getProperties();
} 

The PublishControlPropertiesDocument XML Bean is defined in DynamicProperties.xsd which is located in the Schemas folder of each process application.

To learn more about the methods available on the MB Publish control, see the PublishControl Interface Javadoc.

Method Attributes

The following method attributes determine the behavior of the MB Publish control.

Class attributes include:

Method attributes include:

Example Code for MB Publish Control

The Publish control allows you to override class-level annotations with dynamic properties. To do so, use an XML variable that conforms to the control's dynamic property schema.

The following is an example of an XML variable you can use to specify the dynamic properties:

<PublishControlProperties>
    <channel-name>potopic</channel-name>
    <message-metadata>
        <custom-header>ACME Corp</custom-header>
    <message-metadata>
</PublishControlProperties> 

The XML Schema for the MB Publish control dynamic properties is shown in the following listing. You can obtain this schema by adding the WLI Schemas project template to you application. You can get and set these properties using the getProperties and setProperties methods.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.bea.com/wli/control/dynamicProperties"
xmlns="http://www.bea.com/wli/control/dynamicProperties"
elementFormDefault="qualified">
    <xs:element name="PublishControlProperties">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="channel-name" type="xs:string" 
                            minOccurs="0" maxOccurs="1" />
                <xs:element name="message-metadata" type="header" 
                            minOccurs="0" maxOccurs="1" />
            </xs:sequence>
        </xs:complexType>
    </xs:element> 
<!-- The following complex-type represents any arbitrary sequence of XML content --> 
    <xs:complexType name="header">
        <xs:sequence>
            <xs:any namespace="##other" minOccurs="0" 
                    maxOccurs="unbounded" processContents="lax" />
        </xs:sequence>
    </xs:complexType>
</xs:schema> 

Example Code

MB Publish controls must be extended. The following is an example of how to code a MB Publish control in your JPD file.

/*
 * @jc:mb-publish-control channel-name="/controls/potopic" 
 */ 
interface MyPublishControl extends PublishControl,com.bea.control.ControlExtension {
    /**
     * @jc:mb-publish-method
     *      message-metadata="<custom-header>ACME Corp</custom-header>"
     *      message-body="{myMsgToSend}"
     */ 
    void publishPO(XmlObject myMsgToSend);
}
 
/*
 * @common:control 
 */
private MyPublishControl pubCtrl; 
// publish a message 
void sendIt(XmlObject myMsgToSend) {
    pubCtrl.publishPO(myMsgToSend);
} 
Previous Document Next Document