Creating a New JMS Control

The JMS control enables applications built in WebLogic Workshop to interact with messaging systems that provide a JMS implementation. This topic describes how to create a new JMS control and provides an example of a valid JMS control file.

Adding a New JMS Control to a Web Service or Control

You can add a JMS control in any of the following types of files:

To add a JMS control, follow these steps:
  1. Open the file to which you want to add the control in the WebLogic Workshop design environment.
  2. Display the Data Palette (View->Windows->Data Palette).
  3. On the Data Palette, click the Add drop-down, and choose JMS. The Insert Control - Insert JMS dialog opens.
  4. In Step 1, in the Variable name for this control field, type the name for your JMS control.
  5. In Step 2, select the Create a new JMS control to use radio button.
  6. In the New JCX name field, type the name of the new file.
  7. Decide whether you want to make this a control factory and select or clear the Make this a control factory that can create multiple instances at runtime check box. For more information about control factories, see Control Factories: Managing Collections of Controls.
  8. In Step 3, from the Message type drop-down list, select the type of message you want to process. For more information about the types of messages, see the Configuring a JMS Control.
  9. From the JMS destination type drop-down list, select either Queue or Topic, depending on the kind of messaging service you will be connecting to. For more information about messaging services, see Overview: Messaging Systems and JMS.
  10. In the send-jndi-name field, type the name of the queue or topic that will send messages. If you do not know the name, click Browse and choose from the available list.
  11. In the receive-jndi-name field, type the name of the queue or topic that will receive messages. If you do not know the name, click Browse and choose from the available list.
  12. In the connection-factory field, type the name of the connection factory to create connections to the queue or topic. If you do not know the name, click Browse and choose from the available list.
  13. Click Create.

You can also create a new JMS control file without adding it to a web service or another control file. From the File menu, choose New-->Java Control. Select the JMS control from the list, and follow the instructions to create a new control file.

The values that you provide when you create the control are specified in the control's @jc:jms annotation, as shown in the sample file in the next section.

The JCX File for JMS Control

If you create a new JMS control JCX file using the settings described above, the new JCX file looks like the following example. The contents of the JMS control's JCX file depend on the selections made in the Insert Control - Insert JMS dialog. The following example was generated with Text selected from the Message type drop-down list:

import com.bea.control.*;
import java.io.Serializable;
/** 
 *   @jc:jms send-type="queue" send-jndi-name="jms.SimpleJmsQ"
 *            receive-type="queue" receive-jndi-name="jms.SimpleJmsQ"
 *            connection-factory-jndi-name="weblogic.jws.jms.QueueConnectionFactory"
 */ 
public interface SimpleQueueControl extends JMSControl 
{
    /**
     * this method will send a javax.jms.TextMessage to send-jndi-name
     */
    public void sendTextMessage(String payload);
    /**
     * If your control specifies receive-jndi-name, that is your JWS expects to receive messages 
     * from this control, you will need to implement callback handlers.
     */
    interface Callback extends JMSControl.Callback
    {
        /**
         * Define only 1 callback method here.
         * 
         * This method defines a callback that can handle text messages from receive-jndi-name
         */
         public void receiveTextMessage(String payload);
    }
}

The JCX file contains the declaration of a Java interface with the name specified in the dialog. The interface extends the JMSControl base interface. To learn more about JCX files generated for messages of other types, see Specifying the Body of a Message and Specifying Message Headers and Properties.

Related Topics

JMS Control

Using WebLogic Built-In Controls

Overview: Messaging Systems and JMS

@jc:jms-headers Annotation

@jc:jms-property Annotation

JMSControl Interface