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
Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.
Enter a filename for the MB control in the JCX file field, or click Browse to find the JCX file in your file system.
Note: If no options are available in the channel-name field, you must create a channel file, which defines the channels to which your business process can publish and subscribe. To learn how to create this file, see How Do I: Create Message Broker Channels?.
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:
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); }
This section describes the MB Publish control interface. Use the methods from within your application to publish to Message Broker channels.
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.
The following method attributes determine the behavior of the 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>
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); }
![]() |
![]() |