Restlet (2.0.5)의 ClientResource에 문제가있어 정확한 사용법을 이해하지 못한 결과 일 수 있습니다.Restlet ClientResource를 올바르게 사용하기
나는 아파치 HTTP 클라이언트 커넥터의 ClientResource를 사용하고, 다음과 같은 쓴 :
private final ClientResource httpClient;
public SendClient(String uri) {
httpClient = new ClientResource(uri);
}
// Omitted code would create messages to send, and then use an executor
// to send this particular message to its destination.
public void run() {
ClientResource sendClient = null;
try {
sendClient = wsClient.getChild(uriResource); // re-use original httpclient instance, uriResource is passed in to the method that calls this.
sendClient.post(form);
} catch (Throwable e) {
logger.error("Unable to send message, {}", e.getMessage());
} finally {
if (sendClient != null) {
sendClient.release(); // As I understand from [Restlet WIKI][1]
}
}
}
이 맞습니까? 몇 시간 (7 일 이상)이 코드 섹션에서 "내부 서버 오류"라는 오류가 발생하고 대상에서 메시지를 더 이상 수신하지 못하기 때문에 이것이 아닌 것 같습니다.
내가 잘못하고있는 것에 대한 아이디어가 있습니까?
참고 ClientResource는 스레드로부터 안전하지 않으며,이 코드 섹션을 실행하기 위해 실행 프로그램을 사용하고 있음을 알게 될 것입니다. 그러나 실행 프로그램에는 단일 스레드 만 포함되어 있습니다. 나는 그렇지 않다는 것을 안다. 나는 그것을 문제로 배제했다.
참고 2 : ClientResource javadoc에서는 "동시 처리 메모 : 클래스의 인스턴스가 여러 스레드간에 공유되도록 설계되지 않았으므로 스레드 안전성이 필요하면 하위 Client 클래스를 사용하는 것이 좋습니다." 그러나, restlet 생성자는 실제로이 목적을 위해 명시 적으로 설계되지 않은 스레드 안전하다고 말합니다. 감사합니다. .
감사합니다. –