This forum has been archived. Please start a new discussion on GitHub.

AMD and timing


If I have an AMD method and I do the following
AMethod_async(callback, ...)
      // This publishes to an ice storm topic.

If the client that calls the method also has a subscriber to the topic that publisher publishes to is the client guaranteed to get the result from the method call before getting the ice storm notification?


  • mes
    mes California

    No, it is not guaranteed that the client will receive its reply to the invocation of AMethod before it receives the message from IceStorm. It is quite likely, but not guaranteed. For example, the client thread pool in the client might be busy at the time the server thread pool in the client receives the IceStorm message. If your client needs this guarantee (such as to prevent a race condition), you'll need to handle it in the client.

  • Hi Mark,

    Thanks for the response.

    I'm still trying to picture how it can really happen.

    So the client is calling AMethod_async. The client call is NOT AMI, so a client thread is tied up waiting for the response. Next the server responds using ice_response(). What does it mean when ice_response() returns? Doesn't it mean that the client has gotten the response at that point?

  • benoit
    benoit Rennes, France

    When the ice_response call returns, there are 2 cases:
    • the response is sent immediately to the client. The client will likely receive the response before the publish call in the server but it's not guaranteed because the server doesn't wait for any acknowledgment from the client.
    • the response is queued with the Ice connection for latter sending. This can happen for example if the connection has many or large other responses to send. In this case, you don't really know when the response is sent: it is sent in the background by another server thread (if and when available).

    Your client shouldn't rely on receiving the response before the update from IceStorm since there are no guarantees that it will be the case.