How Do I: Design a Web Service that Involves Long-Running Operations?

WebLogic Workshop introduces the notion of conversations to manage the state of your web service (stored in class member variables) over a long-running sequence of operations and correlate messages between your web service and its clients and controls. To use conversations, you simply set the conversation property on each method or callback, marking it as starting, continuing, or finishing a conversation. When a start method is called, WebLogic Server creates a new record (a conversation instance) for the state of the web service. When continue methods or callbacks are called, the state of the conversation is accessible. After a finish method or callback completes, the conversation state is deleted to release server resources.

To Specify the Conversational Behavior of a Web Service

  1. In Design View, select a method you wish to start a conversation by clicking the method arrow to the left of its name.
  2. In the Properties pane, expand the conversation property.
  3. On the phase attribute, from the drop-down list, select start.
  4. Repeat steps 1 through 3 for each method that can start a conversation.
  5. Select a method you wish to continue the conversation.
  6. In the Properties pane, expand the conversation property.
  7. On the phase attribute, from the drop-down list, select continue.
  8. Repeat from steps 5 through 7 for each method that can continue a conversation.
  9. Select a method you wish to finish the conversation.
  10. In the Properties pane, expand the conversation property.
  11. On the phase attribute, from the drop-down list, select finish.
  12. Repeat steps 9 through 11 for each method that can finish a conversation.

To Specify Conversation Lifetime

Conversations represent server resources and should be released whenever possible. In addition to marking methods of a conversation to control how they affect conversation phase, you can also configure the maximum lifetime or idle time of a conversation. These properties will cause the conversation to be released after a specified period even if (or because) none of the conversational methods have been called. To specify conversation lifetime:

  1. In Design View, select the web service.
  2. In the Properties pane, expand the conversation-lifetime property.
  3. To set the maximum lifetime of a conversation, regardless of whether or when continue or finish methods are called, set the max-age attribute.
  4. To set the maximum idle time of a conversation (the maximum time that may pass between method invocations), set the max-idle-time attribute.

To Make Asynchronous Methods and Callbacks

If you expect that your web service will handle high-volume loads, you should consider using asynchronous methods and callbacks. When a client calls an asynchronous method of your web service, the request is buffered and the method invocation returns to the client immediately. This prevents the client from waiting until your web service handles the request. When the web service sends a message to a client through an asynchronous callback, this outgoing message is buffered on the local machine and the callback invocation returns immediately. This prevents your service from having to wait while the message is sent and the response is received from the client.

You can only add asynchrony to methods and callback whose parameters are serializable and whose return type is void. To make an asynchronous method or callback:

  1. In Design View, select the method or callback you want to make asynchronous.
  2. In the Properties page, expand the message-buffer property.
  3. On the enable attribute, from the drop-down list, select true.

Related Topics

Designing Conversational Web Services

Designing Asynchronous Interfaces

@jws:conversation-lifetime Annotation