Feature/3.0.0-beta how to exit after unsubscribing


#1

I have followed the examples for streaming in https://github.com/datasift/datasift-java/blob/feature/3.0.0-beta/MIGRATING_TO_V-3.0.0.md
After unsubscribing from the only stream that exists using

datasift.liveStream().unsubscribe(stream);

There is still a thread running that is preventing the application from closing.
Is there another method that needs to be called?


#2

The HTTP client uses a thread pool that must be shutdown for the process to end. If you shutdown then you must do a restart before any requests will work. See:

        HttpRequestBuilder.shutdown();
        HttpRequestBuilder.restart();
 

#3

Thanks for the reply,
I’ve been trying to use HttpRequestBuilder.shutdown(); but it still won’t shutdown.

Here is my code:

datasift.liveStream().subscribe(new StreamSubscription(result) {
public void onDataSiftLogMessage(DataSiftMessage di) {
System.out.println((di.isError() ? “Error” : di.isInfo() ? “Info” : “Warning”) + “:\n” + di);
}

        public void onMessage(Interaction interaction) {
            System.out.println("INTERACTION:\n" + interaction);

        }
    });
    Thread.sleep(10000);
    datasift.liveStream().unsubscribe(result);
    HttpRequestBuilder.shutdown();
    </code>

#4

I’ve also tried datasift.shutdown();