# 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 WebLogic Workshop 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 @jc:jms property. Also, specify the send-type attribute as queue. To learn how to create a WLI JMS control, see Creating a New 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:

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 @jc: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 @jc:jms 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 @jc:jms annotation. Also, specify the receive-type 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:

Message Type | Default Method
--- | ---
Text/XMLBean | sendTextMessage
Object | sendObjectMessage
Raw Data | sendBytesMessage
JMS Message | sendRawMessage

4. 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 @jc:jms property. Also, specify the send-type 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 receive-jndi-name attribute of the WLI JMS control's @jc:jms annotation. Also, specify the receive-type 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.

The following is an example of this scenario:

Related Topics

Overview: Messaging Systems and JMS

Messaging Scenarios Not Supported by the WLI JMS Control

WLI JMS Control Interface

@jc:jms Annotation

@jc:jms-headers Annotation

@jc:jms-property Annotation