Hi Paul,
> 1) Is this a legitimate way to build an async client. I want to
> offload the borrow from the connection pool to another thread.
>
> public void send(final BaseMessage message) {
> transport.getWorkerThreadPool().submit(new Runnable() {
> @Override
> public void run() {
> Connection connection = null;
> try {
> connection = pool.borrow();
> connection.write(message);
> } catch (Exception e) {
> throw new ClientException("Failed to send
> message.", e);
> } finally {
> if (connection != null) {
> pool.release(connection);
> }
> }
> }
> });
> }
If you're talking about Grizzly connection pool implementation (AFAIR we
don't have borrow method :)), it might be better to use
pool.take(CompletionHandler), which won't block if there's no available
connection in the pool.
> 2) When using SingleEndpointPool in what order should I close/shutdown
> the pool/transport?
it's probably better to shutdown pool and then transport, but it doesn't
really matter, either way should work.
WBR,
Alexey.