/**
   * Initializes a new instance of the StreamingSubscriptionConnection class.
   *
   * @param service The ExchangeService instance this connection uses to connect to the server.
   * @param lifetime The maximum time, in minutes, the connection will remain open. Lifetime must be
   *     between 1 and 30.
   * @throws Exception
   */
  public StreamingSubscriptionConnection(ExchangeService service, int lifetime) throws Exception {
    EwsUtilities.validateParam(service, "service");

    EwsUtilities.validateClassVersion(
        service, ExchangeVersion.Exchange2010_SP1, this.getClass().getName());

    if (lifetime < 1 || lifetime > 30) {
      throw new ArgumentOutOfRangeException("lifetime");
    }

    this.session = service;
    this.subscriptions = new HashMap<String, StreamingSubscription>();
    this.connectionTimeout = lifetime;
  }