# MQSeries Control Interface

The MQSeries control supports the sending and receiving of messages to and from MQSeries queues. The supported message types are Bytes, String and XML.

The MQSeries control supports two types of connections, that is, TCP and Bindings. The connection options, such as Queue Manager Name, Queue Name and so on, for the MQSeries control can be specified while configuring the MQSeries control.

The following are the MQSeries control methods:

    public interface MQControl extends Control

    {

        /**

         * Begins a MQ transaction

         * @exception ResourceException if transaction state is invalid

         */

        void begin() throws javax.resource.ResourceException;

        /**

         * Rolls back a MQ transaction

         * @exception ResourceException if transaction state is invalid

         */

        void rollback() throws javax.resource.ResourceException;

        /**

         * Commits a MQ transaction

         * @exception ResourceException if transaction state is invalid

         */

        void commit() throws javax.resource.ResourceException;

        /**

         * Sets the dynamic properties for the control.

         * @param mqDynPropsDoc the MQDynamicProperties document containing

         * the dynamic properties to be set

         */

        void setDynamicProperties(com.bea.wli.control.mqDynamicProperties.MQDynamicPropertiesDocument mqDynPropsDoc);

        /**

         * Gets a byte array(binary) message from the queue This function calls the

         * generic getMessage function

         * @param queue the queue from which the message is to be got

         * @param mqmd the MQMDHeaders document containing the MQMD attributes based on which the message is to be got

         * @return byte[] the byte array representing the message got

         * @exception ResourceException if any exception occurs while get

         */

        byte[] getMessageAsBytes(java.lang.String queue, com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd)
        throws javax.resource.ResourceException;

        /**

         * Gets a String(text) message from the queue This function calls the generic

         * getMessage function

         * @param queue the queue from which the message is to be got

         * @param mqmd the MQMDHeaders document containing the MQMD attributes based on which the message is to be got

         * @return String the String representing the message got

         * @exception ResourceException if any exception occurs while get

         */

        java.lang.String getMessageAsString(java.lang.String queue, com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd)
        throws javax.resource.ResourceException;

        /**

         * Gets a XmlObject(xml) message from the queue This function calls the

         * generic getMessage function

         * @param queue the queue from which the message is to be got

         * @param mqmd the MQMDHeaders document containing the MQMD attributes based on which the message is to be got

         * @return XmlObject the XmlObject representing the message got

         * @exception ResourceException if any exception occurs while get

         */

        com.bea.xml.XmlObject getMessageAsXml(java.lang.String queue, com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd)
        throws javax.resource.ResourceException;

        /**

         * Puts a XmlObject(xml) message into the queue This function calls the

         * generic putMessage function

         * @param message the xml message to be put into the queue

         * @param queue the queue to which the message is to be put

         * @param mqmd the MQMDHeaders document containing the MQMD attributes of the message to be put

         * @return MQMDHeadersDocument representing the attributes of the message put

         * @exception ResourceException if any exception occurs while put

         */

        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putMessageAsXml(com.bea.xml.XmlObject message, java.lang.String queue,
        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd) throws javax.resource.ResourceException;

        /**

         * Puts a String(text) message into the queue This function calls the generic

         * putMessage function

         * @param message the String message to be put into the queue

         * @param queue the queue to which the message is to be put

         * @param mqmd the MQMDHeaders document containing the MQMD attributes of the message to be put

         * @return MQMDHeadersDocument representing the attributes of the message put

         * @exception ResourceException if any exception occurs while put

         */

        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putMessageAsString(java.lang.String message, java.lang.String queue,
        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd) throws javax.resource.ResourceException;

        /**

         * Puts a byte array(binary) message into the queue This function calls the

         * generic putMessage function

         * @param message the byte array message to be put into the queue

         * @param queue the queue to which the message is to be put

         * @param mqmd the MQMDHeaders document containing the MQMD attributes of the message to be put

         * @return MQMDHeadersDocument representing the attributes of the message put

         * @exception ResourceException if any exception occurs while put

         */

        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument putMessageAsBytes(byte[] message, java.lang.String queue,
        com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument mqmd) throws javax.resource.ResourceException;

    }

### Sample Extended MQSeries Control

The following code shows an example of an extended control. This code is automatically created by the control wizard.

    package processes;

    import com.bea.control.*;

    import com.bea.xml.XmlCursor;

    import com.bea.control.MQControl;

    import com.bea.wli.control.mqmdHeaders.MQMDHeadersDocument;

    import com.bea.wli.control.mqDynamicProperties.MQDynamicPropertiesDocument;

    import javax.resource.ResourceException;

    import com.bea.xml.XmlObject;

        /*

         * A custom MQ control.

         */

        /**

         * @jc:MQConnectionType connectionType="Bindings"

         * @jc:MQConnectionPoolProps mqPoolSize="20"

         * @jc:ConnectionPoolTimeout conTimeout="3600"

         * @jc:MQQueueManager queueManager="QM_bea_aruna"

         * @jc:MQAuthorization requireAuthorization="No"

         * @jc:TCPSettings host=""

                           port="1414"

                           channel=""

                           ccsid="819"

                           user=""

                           password=""

                           sendExit=""

                           receiveExit=""

                           securityExit=""

         * @jc:DefaultQueue defaultQueueName="default"

         * @jc:ImplicitTransaction implicitTransactionRequired="true"

         */

    public interface newjcx extends MQControl, com.bea.control.ControlExtension

     {

        /*

         * A version number for this JCX. This will be incremented in new versions of

         * this control to ensure that conversations for instances of earlier

         * versions were invalid.

         */

        static final long serialVersionUID = 1L;

    }