Replying to Messages

Generate Reply and Handle Reply tasks can be used to send reply messages without invoking target operations.

In a typical mediation flow for an operation with an in-out message exchange pattern, incoming messages travel along the input path until the message is delivered to the target operation or until a fault is encountered.

In some situations, you might want to send a reply message to the consumer without invoking the target operation. For example, an operation might return the name of the target service. The mediation flow already has the target service name, so you can improve performance and return that information without additional network traffic to the target service.

Another example is a mediation flow with a route task for processing incoming requests. Your mediation flow might return an unchangeable message for one or more routing cases. In that case, you can reply to the consumer without invoking the target service.

You can place the Generate Reply task on an input path to terminate the path and pass control to the output path of the mediation flow. You must map the output message in the Generate Reply Input tab, so that the output message is created in the task.

On the output path, the Handle Reply task intercepts messages from any Generate Reply tasks on the input path and starts the mediation reply path for processing the reply message before it is sent to the consumer.

The diagram shows the operation of the Generate Reply and Handle Reply tasks. In this example, a mediation flow for the createUser operation first invokes the queryUser operation to determine if the user exists. If the user does not exist, the message is delivered to the createUser target operation. If the user already exists, the Generate Reply task is used to return a message notifying the consumer that the user already exists.

Sending a reply message




Placing a Generate Reply task in the Input path automatically creates a mediation reply path with a Handle Reply task. The same Handle Reply task performs all Generate Reply tasks in the Input path.

The Generate Reply task terminates an input path before reaching a target operation. However, you can have more than one Generate Reply task on an input path when a route task splits the input path into multiple sub-paths. One or more sub-paths can end in a Generate Reply task. Generate Reply tasks are executed based on how they are configured in the input flow paths. The Handle Reply task is on the output flow.

After a Generate Reply task is executed, control is passed to the Handle Reply task on the output path. One Handle Reply task accepts reply messages from any Generate Reply task on the input path. The Handle Reply task starts the mediation reply path. Optionally, you can place tasks on the mediation reply path to perform additional processing before the reply message is sent to the consumer. The Handle Reply task and the mediation reply path are automatically placed into the mediation flow when a Generate Reply task is placed on the input path.