This topic describes how to create a new WLI JMS control.
To learn about WLI JMS controls, see WLI JMS Control.
You can create a new WLI JMS control and add it to your business process. To define a new WLI JMS control:
Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.
To learn about the methods available on the WLI JMS control, see the WliJMSControl Interface.
When you create a new WLI JMS control, you create a new JCX file in your project. The following is an example JCX file:
package FunctionDemo; import com.bea.control.*; import com.bea.xml.*; import java.io.Serializable; /** * @jc:jms send-type="queue" send-jndi-name="myqueue.async.request" * receive-type="queue" receive-jndi-name="myqueue.async.response" * connection-factory-jndi-name="weblogic.jws.jms.QueueConnFactory" */ public interface SimpleQueueControl extends WliJMSControl,com.bea.control.ControlExtension { /** * this method will send a javax.jms.TextMessage to send-jndi-name */ public void sendTextMessage(XmlObject payload); /** * this method will send a javax.jms.TextMessage to send-jndi-name */ public void sendAnotherTextMessage(String payload); /** * If your control specifies receive-jndi-name, * that is your process expects to receive messages * from this control, you will need to implement callback handlers. */ interface Callback extends WliJMSControl.Callback { /** * Define only 1 callback method here. * * This method defines a callback that can handle * text messages from receive-jndi-name */ public void receiveTextMessage(XmlObject payload); } }
The JCX file contains the declaration of a Java interface with the name specified in the dialog. The interface extends the control base interface. Invoking any method in the JCX interface, other than the callback, results in a JMS message being sent to the specified queue or topic.
The contents of the WLI JMS control's JCX file depend on the selections made in the Insert WLI JMS dialog. The example above was generated in response to selection of Text/XML Bean as the Message type drop-down list.
Most aspects of a WLI JMS control can be configured from the Properties Editor in Design View. These properties are encoded in the JMS control's JCX file as attributes of the @jc:jms annotation. To retrieve current parameter settings, use the getControlProperties() method. (Note that this is a different method from the getProperties() method on the base JMS control which is used to get the JMS properties of the last message received.)
For detailed information on the @jc:jms annotation and its attributes, see @jc:jms Annotation.
You can also use the ControlContext interface for access to a control's properties at run time and for handling control events. Property values set by a developer who is using the control are stored as annotations on the control's declaration in a JWS, JSP, or JPD file, or as annotations on its interface, callback, or method declarations in a JCX file.
To learn how to create, configure and register JMS queues, topics and connection factories, see Programming WebLogic JMS at the following URL:
http://edocs.bea.com/wls/docs81/jms/index.html
Two queues are configured when WebLogic Workshop is installed, in order to support WLI JMS control samples. These are named SimpleJmsQ and CustomJmsCtlQ. The connection factory that provides connections to these queues has the JNDI name weblogic.jws.jms.QueueConnectionFactory. These resources may be used for experimentation.
Note: Every WLI JMS control deployed on a server should listen on a unique queue. If multiple WLI JMS controls on the same server are simultaneously listening on the same queue, the results may be unpredictable. See the WLI JMS Control Caveats section below for more information.
Within a WLI JMS control, you may define multiple methods and one callback. All methods will send or publish to the queue or topic named by send-jndi-name, if present.
JMS defines several message types that may be sent and or published. The WLI JMS control can send the JMS message types TextMessage, ObjectMessage, BytesMessage, and JMSMessage. The WLI JMS control dynamically determines which type of message to send based on the configuration of the WLI JMS control method that was called. XML Object and XML typed variables use the text/XMLBean message type.
Note: You can send or receive any message type through send and receive methods that take a javax.jms.Message argument. (All message types extend javax.jms.Message.) To send an ObjectMessage, for example, call myControl.getSession() to get the JMS session, then call session.createObjectMessage(), and then send the message.
If the WLI JMS control method takes a single String or XMLObject argument, a javax.jms.TextMessage is sent.
If the WLI JMS control method takes a single argument of type java.lang.Object, a javax.jms.ObjectMessage is sent.
If the WLI JMS control method takes a single argument of type javax.jms.BytesMessage, a javax.jms.BytesMessage is sent.
If the WLI JMS control method takes a single argument of type javax.jms.Message, a JMS Message object is sent directly.
To edit the parameter list controlling the message headers and message properties, display the control in the Design view, select a method, and edit the parameters using the Property Editor pane. You can set parameters programatically using the setProperties() method. To display current parameter settings, use the getControlProperties() method.
You can send additional properties using key-values pairs, using the annotation @jc:jms-property for each pair. You can also edit the parameters directly in the Source view.
The JNDI names specified for send-jndi-name, receive-jndi-name and connection-factory may refer to remote JMS resources. The fully specified form of a JMS resource names is:
jms:{provider-host}/{factory-resource}/ {dest-resource}?{provider-parameters}
jms://host:7001/cg.jms.QueueConnectionFactory/ jws.MyQueue?URI=/drt/Bank.jws
jms://host:7001/MyProviderConnFactory/ MyQueue?SECURITY_PRINCIPAL=foo&SECURITY_CREDENTIALS=bar
Bear in mind the following caveats when you work with WLI JMS controls:
Note: If the destination is configured with a large (or no) retry count and no error destination, the WLI JMS control infrastructure will continue attempting to process the message (unsuccessfully) forever. For information on setting the redelivery limit, see the"Programming WebLogic JMS at http://edocs.bea.com/wls/docs81/jms/index.html.
Overview: Messaging Systems and JMS
![]() |
![]() |