private static void dataSubscription1() throws Exception {
    // Create topics
    try (final SubscriptionTreeSession subscriptionSession =
        new SubscriptionTreeSession(HOST, PORT)) {
      subscriptionSession.open();
      final Properties config = new Properties();
      config.put(TopicConstant.PATH_KEY, "root.db.d1.s1");
      config.put(TopicConstant.START_TIME_KEY, 25);
      config.put(TopicConstant.END_TIME_KEY, 75);
      subscriptionSession.createTopic(TOPIC_1, config);
    }

    int retryCount = 0;
    // Subscription: property-style ctor
    final Properties config = new Properties();
    config.put(ConsumerConstant.CONSUMER_ID_KEY, "c1");
    config.put(ConsumerConstant.CONSUMER_GROUP_ID_KEY, "cg1");
    try (final SubscriptionTreePullConsumer consumer1 = new SubscriptionTreePullConsumer(config)) {
      consumer1.open();
      consumer1.subscribe(TOPIC_1);
      while (true) {
        final List<SubscriptionMessage> messages = consumer1.poll(POLL_TIMEOUT_MS);
        if (messages.isEmpty()) {
          retryCount++;
          if (retryCount >= MAX_RETRY_TIMES) {
            break;
          }
        }
        for (final SubscriptionMessage message : messages) {
          for (final SubscriptionSessionDataSet dataSet : message.getSessionDataSetsHandler()) {
            System.out.println(dataSet.getColumnNames());
            System.out.println(dataSet.getColumnTypes());
            while (dataSet.hasNext()) {
              System.out.println(dataSet.next());
            }
          }
        }
        // Auto commit
      }

      // Show topics and subscriptions
      try (final SubscriptionTreeSession subscriptionSession =
          new SubscriptionTreeSession(HOST, PORT)) {
        subscriptionSession.open();
        subscriptionSession.getTopics().forEach((System.out::println));
        subscriptionSession.getSubscriptions().forEach((System.out::println));
      }

      consumer1.unsubscribe(TOPIC_1);
    }
  }
single pull consumer subscribe topic with path and time range
example/session/src/main/java/org/apache/iotdb/SubscriptionSessionExample.java