users@grizzly.java.net

Async Client

From: Sprague, Paul <psprague_at_paypal.com>
Date: Tue, 18 Feb 2014 18:35:46 +0000

Hello Grizzly Users!,

I have a few questions.

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);
                    }
                }
            }
        });
    }

2) When using SingleEndpointPool in what order should I close/shutdown the pool/transport?

Thanks,
-paul