java.util.concurrent.RejectedExecutionException:org.eclipse.jetty.client.HttpClient

java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.client.HttpClient

我正在Jetty异步HTTP客户机上运行以下程序。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Code is
public static void main(String[] args) throws InterruptedException, TimeoutException, ExecutionException {
            String url2="http://www.google.co.in";

        //  JettyHttp.sendHttpSyncReq(url2);
            JettyHttp.sendHttpAsyncReq(url2);

    }
    public static void sendHttpAsyncReq(String url) throws InterruptedException, TimeoutException, ExecutionException
    {
        SslContextFactory sslContextFactory = new SslContextFactory();
        HttpClient httpClient =new HttpClient(sslContextFactory);
        long total_t1=System.currentTimeMillis();


        httpClient.newRequest(url).send(new Response.CompleteListener() {

            @Override
            public void onComplete(Result arg0) {
                // TODO Auto-generated method stub

            }
        });

        long total_t2=System.currentTimeMillis();
        System.out.println(total_t2-total_t1 +" ==");


    }

我得到的错误是

1
2
3
4
5
6
7
Exception in thread"main" java.util.concurrent.RejectedExecutionException: org.eclipse.jetty.client.HttpClient@412429c is stopped
    at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:198)
    at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:485)
    at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:486)
    at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:479)
    at com.nielsen.http.JettyHttp.sendHttpAsyncReq(JettyHttp.java:38)
    at com.nielsen.http.JettyHttp.main(JettyHttp.java:28)

请帮我纠正错误:


你忘了启动httpclient。

1
2
3
SslContextFactory sslContextFactory = new SslContextFactory();
HttpClient httpClient =new HttpClient(sslContextFactory);
httpClient.start();

请记住,您的所有请求和连接只需要1个HttpClientHttpClient对象与浏览器具有相同的逻辑角色,它管理许多连接选项卡。