无法停止在皮卡消费

时间:2019-05-16 09:48:36

标签: python python-3.x pika

由于org.apache.commons.httpclient final HttpClient httpClient = new HttpClient(); String url; // your URL String body; // your JSON final int contentLength = body.length(); PostMethod postMethod = new PostMethod(url); postMethod.setRequestHeader("Accept", "application/json"); postMethod.setRequestHeader("Content-Type", "application/json; charset=utf-8"); postMethod.setRequestHeader("Content-Length", String.valueOf(contentLength)); postMethod.setRequestEntity(new StringRequestEntity(body, "application/json", "utf-8")); final int statusCode = httpClient.executeMethod(postMethod); if (statusCode != 200) throw new java.io.IOException(statusCode + ": " + HttpStatus.getStatusText(statusCode)); java.io.InputStream responseBodyAsStream = postMethod.getResponseBodyAsStream(); java.io.StringWriter writer=new StringWriter(); org.apache.commons.io.IOUtils.copy(responseBodyAsStream,writer,java.nio.charset.StandardCharsets.UTF_8); String responseJSON=writer.toString(); 没有停止,我无法从Pika返回数据。它打印结果,但不返回输出

start_consuming

1 个答案:

答案 0 :(得分:0)

通过设计start_consuming可以永远阻止。您将必须使用on_request方法取消使用方。

您还可以使用this method来使用允许设置inactivity_timeout的消息,然后您可以在其中取消使用方。

最后,SelectConnection在与Pika的I / O循环进行交互时提供了更大的灵活性,当您的要求比BlockingConnection所支持的要求更复杂时,建议使用它。


注意: RabbitMQ团队监视rabbitmq-users mailing list,并且有时仅在StackOverflow上回答问题。