Using Integration Controls

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

WLI JMS Control

The WLI JMS control is available in BEA WorkSpace Studio only if you are licensed to use WebLogic Integration.

JMS (Java Message Service) is a Java API for communicating with messaging systems. Messaging systems are often packaged as products known as Message-Oriented Middleware (MOMs). WebLogic Server includes built in messaging capabilities via WebLogic JMS, but can also work with third-party MOMs. Messaging systems are often used in enterprise applications to communicate with legacy systems, or for communication between business components running in different environments or on different hosts.

The WLI JMS control enables BEA WorkSpace Studio business processes to easily interact with messaging systems that provide a JMS implementation. A specific WLI JMS control is associated with particular facilities of the messaging system. Once a WLI JMS control is defined, business processes may use it like any other WebLogic Workshop control.

The WLI JMS control provides additional features such as RawData message type support, dynamic property configuration, and the ability to control whether to start a new transaction or remain within the calling transaction. You can use the JMS Event Generator to poll for and consume messages produced by the WLI JMS control.

For information on how to add control instances to business processes, see Using Controls in Business Processes.

 


Topics Included in This Section

Overview: Messaging Systems and JMS

Describes messaging services in general and the Java Message Service in particular

Messaging Scenarios Supported by the WLI JMS Control

Describes appropriate scenarios in which the WLI JMS control may be used.

Messaging Scenarios Not Supported by the WLI JMS Control

Describes scenarios in which the WLI JMS control may not be used.

Creating a WLI JMS Control

Describes how to create and configure a WLI JMS control.

 


Overview: Messaging Systems and JMS

This topic describes the characteristics of messaging systems that are accessible via JMS (Java Message Service), and therefore via the WLI JMS control.

To learn about the WLI JMS control, see WLI JMS Control.

To learn about specific messaging scenarios that are supported by the WLI JMS control, see Messaging Scenarios Supported by the WLI JMS Control.

Messaging Systems

Messaging systems provide communication between software components. A client of a messaging system can send messages to, and receive messages from, any other client. Each client connects to a messaging server that provides facilities for sending and receiving messages. WebLogic JMS, which is a component of WebLogic Server is an example of a messaging server. WebLogic Server also supports third party messaging systems.

Messaging systems provide distributed communication that is asynchronous. A component sends a message to a destination. A message recipient can retrieve messages from a destination. The sender and receiver do not communicate directly. The sender only knows that a destination exists to which it can send messages, and the receiver also knows there is a destination from which it can receive messages. As long as they agree what message format and what destination to use, the messaging system will manage the actual message delivery.

Messaging systems also may provide reliability. The specific level of reliability is typically configurable on a per-destination or per-client basis, but messaging systems are capable of guaranteeing that a message will be delivered, and that it will be delivered to each intended recipient exactly once.

JMS supports two basic styles of message-based communications: point-to-point and publish and subscribe.

JMS Queues for Point-to-Point Messaging

Point-to-point messaging is accomplished with JMS queues. A queue is a specific named resource that is configured in a JMS server.

A JMS client, of which the WLI JMS control is an example, may send messages to a queue or receive messages from a queue. Point-to-point messages have a single consumer. Multiple receivers may listen for messages on the same queue, but once any receiver retrieves a particular message from the queue that message is consumed and is no longer available to other potential consumers.

A message consumer acknowledges receipt of every message it receives.

The messaging system will continue attempting to resend a particular message until a predetermined number of retries have been attempted.

JMS Topics for Publish and Subscribe Messaging

Publish and subscribe messaging is accomplished with JMS topics. A topic is a specific named resource that is configured in a JMS server.

A JMS client, of which the WLI JMS control is an example, may publish messages to a topic or subscribe to a topic. Published messages have multiple potential subscribers. All current subscribers to a topic receive all messages published to that topic after the subscription becomes active.

Connection Factories

Before a JMS client can send or receive messages to a queue or topic, it must obtain a connection to the messaging system. This is accomplished via a connection factory. A connection factory is a resource that is configured by the message server administrator. The names of connection factories are stored in a JNDI directory for lookup by clients wishing to make a connection.

There is a default connection factory pre-configured in WebLogic Workshop, named cgConnectionFactory. This connection factory is used for all WLI JMS controls that do not explicitly override it. If you use a connection factory other than the default connection factory, the factory must have the following setting:

userTransactionsEnabled="true"

Message Components

The components of a JMS message are as follows: a set of standard header fields, a set of application-specific properties, and a message body. Every JMS message contains a standard set of header fields that is included by default and available to message consumers. Some fields can be set by the message producers. The property fields of a message contain header fields added by the sending application. The properties are standard Java name/value pairs. A message body contains the content being delivered from producer to consumer. You can manipulate the content of these components using the following annotations:

JMSHeader Annotation

JMSProperty Annotation

 


Messaging Scenarios Supported by the WLI JMS Control

This topic describes specific messaging scenarios that are supported by the WLI JMS control.

To learn more about JMS, the Java Message Service, see Overview: Messaging Systems and JMS.

To learn more about the WLI JMS control, see WLI JMS Control.

Supported Messaging Scenarios

The JMS specification supports a wide variety of messaging scenarios. Some scenarios that are possible in standalone applications are not possible in the BEA WorkSpace Studio environment due to the nature of web services.

The messaging scenarios in the following sections are supported by the WLI JMS control. For descriptions of messaging scenarios that are not supported by the WLI JMS control, see Messaging Scenarios Not Supported by the WLI JMS Control.

Send Messages to a Queue

A business process, via a WLI JMS control, may send messages to a JMS queue. The business process will not receive a reply. The queue must exist and be registered in the JNDI registry. The administrator who configures the target JMS queue determines the delivery guarantee policies.

To implement this example scenario:

  1. On the WLI JMS control, specify the name of the target JMS queue as the value of the send-jndi-name attribute of the WLI JMS control's @com.bea.control.JMSControl.JMS annotation. Also, specify the sendtype attribute as queue. To learn how to create a WLI JMS control, see Creating a WLI JMS Control.
  2. From your web service, call the WLI JMS control's default method depending on the message type selected when the control was created, or call a custom method you have defined for the WLI JMS control. The default method by message type is as follows:
  3. Table 16-1 Message Type
    Message Type
    Default Method
    Text/XMLBean
    sendTextMessage
    Object
    sendObjectMessage
    Raw Data
    sendBytesMessage
    JMS Message
    sendRawMessage

Two-Way Messaging with Queues

A business process, via a WLI JMS control, may send messages to one queue and receive reply messages on another queue. A single WLI JMS control may have both send and receive queues configured, and business processes may then send and receive via the same control.

Note: Two-way messaging requires correlation of every received messages with the instance of the business process that sent the original outgoing message. The WLI JMS control ensures that the conversation ID of the sender is sent on the send_correlation_property of the outgoing message. To learn more about message correlation, see the explanation of the send-correlation-property and receive-correlation-property attributes in JMSControl.JMS Annotation.

To implement this example scenario:

  1. On the WLI JMS control, specify the name of the JMS queue to which you want to send messages as the value of the send-jndi-name attribute of the JMS control's @ annotation. Also, specify the send-type attribute as queue.
  2. Specify the name of the JMS queue from which you want to receive messages as the value of the receive-jndi-name attribute of the WLI JMS control's @com.bea.control.JMSControl.JMS annotations. Also, specify the receivetype attribute as queue.
  3. From your web service, call the WLI JMS control's default method depending on the message type selected when the control was created, or call a custom method you have defined for the WLI JMS control. The default method by message type is as follows:
  4. Table 16-2 Message Type (Two-Way Messaging)
    Message Type
    Default Method
    Text/XMLBean
    sendTextMessage
    Object
    sendObjectMessage
    Raw Data
    sendBytesMessage
    JMS Message
    sendRawMessage

  5. To be notified when messages are received on the receive queue, implement a callback handler for the WLI JMS control’s callback (receiveTextMessage, receiveBytesMessage, receiveObjectMessage or receiveRawMessage depending on the message type selected when the control was created); or a custom callback you have defined for the WLI JMS control.

Publish to a Topic

A business process, via a WLI JMS control, may publish messages to a JMS topic. The business process will not receive a reply. The topic must exist and be registered in the JNDI registry.

To implement this example scenario:

  1. On the WLI JMS control, specify the name of the target JMS topic as the value of the send-jndi-name attribute of the WLI JMS control's @com.bea.control.JMSControl.JMS annotation. Also, specify the sendtype attribute as topic.
  2. From your business process, call the WLI JMS control's default method (sendTextMessage, sendBytesMessage, sendObjectMessage or sendRawMessage depending on the message type selected when the control was created); or a custom method you have defined for the WLI JMS control.

Subscribe to a Topic

A business process, via a WLI JMS control, may subscribe to messages on a JMS topic. The topic must exist and be registered in the JNDI registry. Only messages sent after the business process has subscribed to the topic will be received.

To implement this example scenario:

  1. On the WLI JMS control, specify the name of the target JMS topic as the value of the receivejndiname attribute of the WLI JMS control's @com.bea.control.JMSControl.JMS annotation. Also, specify the receivetype attribute as topic.
  2. From your business process, call the WLI JMS control's subscribe method.
  3. To be notified when messages are received on the receive topic, implement a callback handler for the WLI JMS control’s callback (receiveTextMessage, receiveBytesMessage, receiveObjectMessage or receiveRawMessage depending on the message type selected when the control was created); or a custom callback you have defined for the WLI JMS control.
  4. To stop being notified when messages are received on the receive topic, call the WLI JMS control’s unsubscribe method.

 


Messaging Scenarios Not Supported by the WLI JMS Control

This topic describes specific messaging scenarios that are not supported by the WLI JMS control.

To learn more about the WLI JMS control, see WLI JMS Control.

Unsupported Scenarios

The JMS specification supports a wide variety of messaging scenarios. Some scenarios that are possible in standalone applications are not possible in the BEA WorkSpace Studio environment due to the nature of web services.

The messaging scenarios in the following section are not supported by the WLI JMS control. For descriptions of messaging scenarios that are supported by the WLI JMS control, see Messaging Scenarios Supported by the WLI JMS Control.

Receive Unsolicited Messages from a Queue

A business process may not, via a WLI JMS control, specify a receive queue and subsequently receive unsolicited messages from that queue.

A business process must be performing work on behalf of a specific client and, in asynchronous situations, as part of a specific conversation. When an unsolicited messages is received from a queue, it is not possible for the WLI JMS control to determine the appropriate conversation or client with which to correlate unsolicited incoming messages.

Note: You may receive unsolicited messages in a business process via the JMS Event Generator and the Message Broker capabilities. To learn how to use the Message Broker controls and the JMS Event Generator, see Message Broker Controls.

 


Creating a WLI JMS Control

This topic describes how to create a new WLI JMS control.

To learn about WLI JMS controls, see WLI JMS Control.

Creating a New 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:

  1. In the Package Explorer pane, double-click the business process (Process.java file) to which you want to add the WLI JMS control. The business process is displayed in the Design view.
  2. Click Insert Control - JMS<img src=" id="wp1103119"/> on the Data Palette and from the drop-down list choose Integration Controls to display the list of controls used for integrating applications.
  3. Note: If the Data Palette view is not visible in BEA WorkSpace Studio, click
    Window > Show View > Data Palette from the menu bar.
  4. Select WLI JMS.
  5. The Insert control: WLI JMS dialog box appears (see Figure 16-1).

    Figure 16-1 Insert Control: WLI JMS


    Insert Control: WLI JMS

  6. In the Insert control: WLI JMS dialog box enter the following details:
    • In the Field Name, type the variable name used to access the new WLI JMS control instance from your business process. The name you enter must be a valid Java identifier.
    • In the Insertion point: from the drop-down list select the point where you want the field name to be inserted in the process file.
    • 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.
    • Click Next.
    • The Create Control dialog-box appears.

  7. In the Create Control dialog box enter the following details:
    • In the Name field, type the name of your new control extension file.
    • Decide whether you want to add comments as configured in the properties of the current project and select or clear the Generate comments check box.
    • Click Next.
    • The Insert control- JMS dialog-box appears (see Figure 16-2).

      Figure 16-2 Insert Control - JMS
      Insert Control: WLI JMS
  8. In the Insert control- JMS dialog box enter the following details:
    • In the Message type drop-down list, select the type of message you want to process. For more information about the types of messages, see Specifying the Format of The Message Body.
    • In the JMS send 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.
    • In the Name of Queue on which to send message 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. You must specify the name of the send queue if the control is to be used to send messages.
    • In the JMS receive 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.
    • In the Name of queue on which to receive messages 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. You must specify the name of the receive queue if the control is to be used to receive messages.
    • In the connection-factory to create connections to the queue 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.
    • Click Finish.

WLI JMS Control Methods

To learn about the methods available on the WLI JMS control, see the Interface WliJMSControl.

The Java File for a WLI JMS Control

When you create a new WLI JMS control, you create a new Java file in your project. The following is an example Java file:

package requestquote;
@org.apache.beehive.controls.api.bean.ControlExtension
@com.bea.control.JMSControl.JMS(sendtype = com.bea.control.JMSControl.Type.queue, sendjndiname = "l", receivetype = com.bea.control.JMSControl.Type.queue, receivejndiname = "l", connectionfactoryjndiname = "o")
public interface WLIJMSCntrl extends com.bea.control.WliJMSControl {
	/**
	 * this method will send a javax.jms.TextMessage to sendJndiName
	 */
	public void sendTextMessage(String payload);
	/**
	 * If your control specifies receiveJndiName, that is your JWS expects to receive
	 * messages from this control, you will need to implement callback handlers.
	 */
	@org.apache.beehive.controls.api.events.EventSet(unicast = true)
	interface Callback extends com.bea.control.WliJMSControl.Callback {
		/**
		 * Define only 1 callback method here.
		 *
		 
		 * This method defines a callback that can handle text messages from receiveJndiName
		 */
		public void receiveTextMessage(String payload);
	}
	static final long serialVersionUID = 1L;
	public WLIJMSCntrl create();
}


The Java 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 Java 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 Java 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.

Configuring the Properties of a JMS Control

Most aspects of a WLI JMS control can be configured from the JPD Configuration pane in Design view. These properties are encoded in the JMS control's Java file as attributes of the @com.bea.control.JMSControl.JMS annotations. To retrieve current parameter settings, use the getControlProperties() method (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 more information about the JMSControl:JMS annotation and its attributes, see JMSControl:JMS Annotation.

Two queues are configured when BEA WorkSpace Studio 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, for more information see WLI JMS Control Caveats.

Specifying the Format of The Message Body

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.

Specifying Message Headers and Properties

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 JPD Configuration 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 @com.bea.control.JMSControl.JMS -property for each pair. You can also edit the parameters directly in the Source view.

Accessing Remote JMS Resources

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}

For example:

jms://host:7001/cg.jms.QueueConnectionFactory/
jws.MyQueue?URI=/drt/Bank.jws

or:

jms://host:7001/MyProviderConnFactory/
MyQueue?SECURITY_PRINCIPAL=foo&SECURITY_CREDENTIALS=bar

WLI JMS Control Caveats

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 the message (unsuccessfully) forever. For information on setting the redelivery limit, see “ Programming WebLogic JMS”.

  Back to Top       Previous  Next