Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbstractClientBuilder.SHARED_IDLE_CLEANUP_SCHEDULER prevents application from closing #105

Closed
mathieucarbou opened this issue Apr 26, 2014 · 2 comments
Labels
Milestone

Comments

@mathieucarbou
Copy link

    HttpClient<ByteBuf, ByteBuf> client = new HttpClientBuilder<ByteBuf, ByteBuf>('localhost', 8080)
            .//withNoIdleConnectionCleanup()
            .withMaxConnections(DEFAULT_MAX_CONNECTIONS)
            .build()

        println client.submit(HttpClientRequest.createPost('/api/profile/login')
           // [...]
          .toBlockingObservable().last()

        client.shutdown()

Without withNoIdleConnectionCleanup, a static 1-thread scheduler is created and prevents application from closing.

=> Why it is shared ? Could it just be instanciated per client, since each client aslo schedules its own cleanup task and delay ? Ansi since each client can handle a lot of connections, there shouldn't be so much client instances within an app ?

Thank you ;-)

@NiteshKant
Copy link
Member

With or without withNoIdleConnectionCleanup, a static 1-thread scheduler is created and prevents application from closing.

I will make the thread used by the default executor as a daemon.

Why it is shared ? Could it just be instanciated per client, since each client aslo schedules its own cleanup task and delay ?

Default is a shared cleanup scheduler, one can use a different scheduler per client using this method:

new ClientBuilder("localhost", 8080).withPoolIdleCleanupScheduler(Executors.newScheduledThreadPool(1));

since each client can handle a lot of connections, there shouldn't be so much client instances within an app ?

An RxClient is dedicated to a host+port combination (the interface supports one RxClient dedicated to a pool of homogeneous servers) so an application will have as many clients as the number of hosts it connects to. All the resources used by an RxClient like eventloops, cleanup threads, etc. can be shared and hence an RxClient does not have any overhead per se, so there isn't an issue creating multiple clients.

@mathieucarbou
Copy link
Author

Ok! Thank you for the very fast answers :-) I will wait for the new version.

@NiteshKant NiteshKant added this to the 0.3.4 milestone Apr 28, 2014
@NiteshKant NiteshKant added the bug label May 5, 2014
@NiteshKant NiteshKant self-assigned this May 5, 2014
NiteshKant pushed a commit to NiteshKant/RxNetty that referenced this issue May 6, 2014
- Implemented Infrastructure contexts (Fixes Issue ReactiveX#101)
- Fixed issue ReactiveX#55 (Wire debugging)
- Fixed issue ReactiveX#105 Made the global idle connection cleanup thread a daemon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants