# Message Broker Publish Control Interface

The Message Broker Publish control is used 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.

The following are the Message Broker Publish control methods:

    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 for 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();
    }

### Sample Extended Publish Control

The following code shows an example of an extended control.

    /*
     * @jc:mb-publish-control channel-name="/controls/potopic"
     */

    public 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);
    }

The following code shows how a JPD uses the control:

    /*
     * @common:control
     */
    private MyPublishControl pubCtrl;

    // publish a message
    void sendIt(XmlObject myMsgToSend) {
        pubCtrl.publishPO(myMsgToSend);
    }