2012-02-06 17 views
2

我正在使用分佈式OSGi和Zookeeper構建分佈式應用程序。應用程序應運行在Felix和Equinox上。我使用BundleContext.registerService(...)將我的服務註冊爲JAX-WS webservices,並使用ServiceTracker<S,T>查詢它們。所以所有的服務處理都是由OSGi框架完成的。每個服務調用都會進行一些計算,因此在響應調用者之前需要一些時間。分佈式OSGi:讀取超時

問題是,當服務調用需要60秒以上時,我得到java.net.SocketTimeoutException: Read timed out異常。所以似乎有60秒的默認超時時間。有誰知道我可以如何配置OSGi框架使用的超時?

這是一個完整的堆棧跟蹤:

Feb 06, 2012 11:27:02 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging 
WARNING: Interceptor for {http://test.com/}LB#{http://test.com/}createSession has thrown exception, unwinding now 
org.apache.cxf.interceptor.Fault: Could not send Message. 
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313) 
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265) 
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) 
    at org.apache.cxf.frontend.ClientProxy.invoke(ClientProxy.java:68) 
    at $Proxy34.createSession(Unknown Source) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:601) 
    at org.apache.cxf.dosgi.dsw.handlers.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:65) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at org.apache.cxf.dosgi.dsw.handlers.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:63) 
    at $Proxy34.createSession(Unknown Source) 
    at test.Consumer$LoadGeneratingThread.run(Consumer.java:122) 
Caused by: java.net.SocketTimeoutException: SocketTimeoutException invoking http://192.168.0.15:9090/LB: Read timed out 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525) 
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2058) 
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2043) 
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) 
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:639) 
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) 
    ... 16 more 
Caused by: java.net.SocketTimeoutException: Read timed out 
    at java.net.SocketInputStream.socketRead0(Native Method) 
    at java.net.SocketInputStream.read(SocketInputStream.java:150) 
    at java.net.SocketInputStream.read(SocketInputStream.java:121) 
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) 
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) 
    at java.io.BufferedInputStream.read(BufferedInputStream.java:334) 
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:641) 
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:589) 
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1319) 
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) 
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2165) 
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2134) 
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1988) 
    ... 19 more 
+0

對於其他人:我從郵件列表中得到了一個答案,告訴我超時在Apache CXF中尚未配置。唯一的可能是使用版本1.3支持的自定義CXF攔截器,並使用它來更改每個請求的HTTPConduit。自從我發現CXF出現更多問題後,我沒有嘗試這麼做,因此我無法告訴您它是否可行。 – 2012-02-14 13:31:05

回答

1

我解決了這個問題。我使用CXF-dosgiりsinglebundle分佈-1.2.jar 打開文件/META-INF/cxf/cxf.xml並添加一些內容:

xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" 
xsi:schemaLocation="...... 
http://cxf.apache.org/transports/http/configuration 
http://cxf.apache.org/schemas/configuration/http-conf.xsd" 

<http-conf:conduit name="*.conduit"> 
    <http-conf:client ConnectionTimeout="10000" ReceiveTimeout="20000"/> 
</http-conf:conduit> 

那現在是確定!