Transport.SendRequest

Method

Visual Basic

Overrideable Public Function SendRequest (
    ByVal request As Message,
    ByVal timeout As Double )
  As Message

C#

public virtual Message SendRequest (
    Message request,
    double timeout );

Purpose

Send a request message and wait for a reply.

Blocking can Stall Event Dispatch

Warning 

This call blocks all other activity on its program thread. If appropriate, programmers must ensure that other threads continue dispatching events on its queues.

Parameter

Description

request

Send this message.

timeout

Maximum time (in seconds) that this call can block while waiting for a reply.

TimeoutValue.WaitForever indicates no timeout (wait without limit for a reply).

Remarks

When the method receives a reply, it returns the reply. When the call does not receive a reply, it returns null, indicating timeout.

Programs that receive and process the request message cannot determine that the sender has blocked until a reply arrives.

The request message must have a valid destination subject; see SendSubject.

Operation

This method operates in several synchronous steps:

Procedure 

1. Create an inbox name, and an event that listens to it. Overwrite any existing reply subject of message with the inbox name.
2. Send the outbound message.
3. Block until the listener receives a reply; if the time limit expires before a reply arrives, then return null. (The reply circumvents the event queue mechanism, so it is not necessary to explicitly call dispatch methods in the program.)
4. Return the reply as the value of this method.