Interface AsyncMethodHandler


public interface AsyncMethodHandler
A MicroAgent that supports async methods must implement this interface. The methods of this interface are used to subscribe to async methods of microagents. A "subscription session" for a particular MethodSubscription is defined as beginning and ending with the corresponding calls to the start/stopAsyncMethodSubscription() methods with equivalent(defined by MethodSubscription.equals()) MethodSubscription arguments. There can only be one subscription session at a time for each MethodSubscription. In other words, once startAsyncMethodSubscription() is called for a particular MethodSubscription object, it will not be called again until after stopAsyncMethodSubscription() is called for that same MethodSubscription. The microagent is responsible for servicing a subscription for the duration of a subscription session by forwarding data and errors to the AsyncDataHandler supplied in the startAsyncMethodSubscription() method.
  • Method Details

    • startAsyncMethodSubscription

      void startAsyncMethodSubscription(MethodSubscription msub, AsyncDataHandler h) throws MicroAgentException
      Used to start a subscription for an async method.

      When invoked, microagents implementing this interface should begin asynchronous delivery of the subscribed-to data through the supplied AsyncDataHandler.

      This method will be called only once for each unique subscription (defined by the MethodSubscription arguemnt) and may not be invoked again for that same subscription until after the corresponding stopAsyncMethodSubscription() method has been called for this subscription. The supplied AsyncDataHandler

      There are two general types of errors that can occur with method subscriptions:

      1. During the registration of the subscription. This condition should cause this method to throw a MicroAgentException.
      2. During the servicing of the subscription. These errors should be delivered to the onError() method of the supplied AsyncDataHandler. When the error condition clears, the AsyncDataHandler's onErrorCleared() method should be called.
      Parameters:
      msub - Identifies what is being subscribed to.
      h - The object that handles the subscribed to data and errors that occur after successful registration.
      Throws:
      MicroAgentException - If an error occurs during the initialization of the subscription.
    • stopAsyncMethodSubscription

      void stopAsyncMethodSubscription(MethodSubscription msub) throws MicroAgentException
      Used to stop a subscription for an async method.

      When invoked, microagents implementing this interface should stop servicing the identified subscription and discard the AsyncDataHandler supplied in the corresponding startAsyncMethodSubscription() call identified by the same MethodSubscription.

      Parameters:
      msub - Identifies what is being subscribed to.
      h - The object that handles the subscribed to data and errors that occur after successful registration.
      Throws:
      MicroAgentException - If an error occurs during the termination of the subscription.