Hi All

I was trying to use a custom connection pool implementation extending the BasicNIOConnPool for sending messages. My use case requires me to use different socket timeouts for different requests. When I want to send out messages, I do something like the following (code simplified for illustration)

        final BasicHttpContext coreContext = new BasicHttpContext();
        coreContext.setAttribute("timeout", 3000);
asyncRequester.execute(requestProducer, responseConsumer, connectionPool, coreContext);


My connection pool overrides the requestCompleted() method, and tries to read the socket timeout I had set earlier

public class UltraNIOConnPool extends BasicNIOConnPool {
    protected void requestCompleted(SessionRequest request) {
        super.requestCompleted(request);
Integer timeout = (Integer) request.getSession().getAttribute("timeout");
        if (timeout != null) {
NHttpClientConnection conn = (NHttpClientConnection) request.getSession().getAttribute(ExecutionContext.HTTP_CONNECTION);
            conn.setSocketTimeout(timeout);
        }
    }
}

However, the values I put into the coreContext above is not available in the session within the requestCompleted(). I need to set the socket timeout before the new connection is used. I am quite sure I am overlooking something simpler.. so any help is very much appreciated

regards
asankha

--
Asankha C. Perera
AdroitLogic, http://adroitlogic.org

http://esbmagic.blogspot.com




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to