You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by mcoogan <mi...@daon.com> on 2007/11/30 18:54:55 UTC

Thread hangs when processing large response message using LocalTransport with dispatchDirect


I am running a local transport configured with DISPATCH_DIRECT = true. Small
request/response messages process successfully but any request that
generates a response > 1KB seems to hang the JVM. The problem appears to be
in the PipedInput/OutputStreams. If the buffer (default size 1024B) fills up
it is never flushed and the thread appears to hang in an eternal wait
(PipedInputStream.awaitSpace())

The PipedInput and PipedOutput Streams are on the same thread and therefore
the buffer is never cleared until after the stream is closed. 

Has anyone else seen this problem or is it something I am missing in the
configuration. 

Here's a code snippet of how I send the local


        InputStream in = null;
    	MyMessageObserver mo = new MyMessageObserver();
    	
	try {
		EndpointInfo ei = new EndpointInfo(null,
"http://schemas.xmlsoap.org/soap/http");
		ei.setAddress(address);
		
		LocalConduit conduit = (LocalConduit)localTransport.getConduit(ei);
		conduit.setMessageObserver(mo);		
		
		Message msg = new MessageImpl();
		msg.put(LocalConduit.DIRECT_DISPATCH, true);
					
		in = new ByteArrayInputStream(messsageBytes);
		msg.setContent(InputStream.class, in);
		
		conduit.close(msg);
		return  mo.getResponseStream().toByteArray();
			
	}		        
	finally {
		
		try {
			if(in != null) {
				in.close();	
			}				
		} catch (Exception e) {
			logger.error("Error closing Stream: "+ e.getMessage());
		}
	}


Thanks in advance



-- 
View this message in context: http://www.nabble.com/Thread-hangs-when-processing-large-response-message-using-LocalTransport-with-dispatchDirect-tf4922460.html#a14086696
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Thread hangs when processing large response message using LocalTransport with dispatchDirect

Posted by mcoogan <mi...@daon.com>.

Thanks Dan. I've logged a JIRA against this issue (CXF-1245)




dkulp wrote:
> 
> 
> Yea, that looks very bad.    Pipes should NEVER be used on a single 
> thread.   That will definitely cause a hang.   Can you log a JIRA?
> 
> It probably should use a CachedOutputStream and then grab the inputstream 
> in the dispatchDirect method.
> 
> Dan
> 
> 
> On Friday 30 November 2007, mcoogan wrote:
>> I am running a local transport configured with DISPATCH_DIRECT = true.
>> Small request/response messages process successfully but any request
>> that generates a response > 1KB seems to hang the JVM. The problem
>> appears to be in the PipedInput/OutputStreams. If the buffer (default
>> size 1024B) fills up it is never flushed and the thread appears to
>> hang in an eternal wait (PipedInputStream.awaitSpace())
>>
>> The PipedInput and PipedOutput Streams are on the same thread and
>> therefore the buffer is never cleared until after the stream is
>> closed.
>>
>> Has anyone else seen this problem or is it something I am missing in
>> the configuration.
>>
>> Here's a code snippet of how I send the local
>>
>>
>>         InputStream in = null;
>>     	MyMessageObserver mo = new MyMessageObserver();
>>
>> 	try {
>> 		EndpointInfo ei = new EndpointInfo(null,
>> "http://schemas.xmlsoap.org/soap/http");
>> 		ei.setAddress(address);
>>
>> 		LocalConduit conduit = (LocalConduit)localTransport.getConduit(ei);
>> 		conduit.setMessageObserver(mo);
>>
>> 		Message msg = new MessageImpl();
>> 		msg.put(LocalConduit.DIRECT_DISPATCH, true);
>>
>> 		in = new ByteArrayInputStream(messsageBytes);
>> 		msg.setContent(InputStream.class, in);
>>
>> 		conduit.close(msg);
>> 		return  mo.getResponseStream().toByteArray();
>>
>> 	}
>> 	finally {
>>
>> 		try {
>> 			if(in != null) {
>> 				in.close();
>> 			}
>> 		} catch (Exception e) {
>> 			logger.error("Error closing Stream: "+ e.getMessage());
>> 		}
>> 	}
>>
>>
>> Thanks in advance
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/Thread-hangs-when-processing-large-response-message-using-LocalTransport-with-dispatchDirect-tf4922460.html#a14105264
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Thread hangs when processing large response message using LocalTransport with dispatchDirect

Posted by Daniel Kulp <dk...@apache.org>.
Yea, that looks very bad.    Pipes should NEVER be used on a single 
thread.   That will definitely cause a hang.   Can you log a JIRA?

It probably should use a CachedOutputStream and then grab the inputstream 
in the dispatchDirect method.

Dan


On Friday 30 November 2007, mcoogan wrote:
> I am running a local transport configured with DISPATCH_DIRECT = true.
> Small request/response messages process successfully but any request
> that generates a response > 1KB seems to hang the JVM. The problem
> appears to be in the PipedInput/OutputStreams. If the buffer (default
> size 1024B) fills up it is never flushed and the thread appears to
> hang in an eternal wait (PipedInputStream.awaitSpace())
>
> The PipedInput and PipedOutput Streams are on the same thread and
> therefore the buffer is never cleared until after the stream is
> closed.
>
> Has anyone else seen this problem or is it something I am missing in
> the configuration.
>
> Here's a code snippet of how I send the local
>
>
>         InputStream in = null;
>     	MyMessageObserver mo = new MyMessageObserver();
>
> 	try {
> 		EndpointInfo ei = new EndpointInfo(null,
> "http://schemas.xmlsoap.org/soap/http");
> 		ei.setAddress(address);
>
> 		LocalConduit conduit = (LocalConduit)localTransport.getConduit(ei);
> 		conduit.setMessageObserver(mo);
>
> 		Message msg = new MessageImpl();
> 		msg.put(LocalConduit.DIRECT_DISPATCH, true);
>
> 		in = new ByteArrayInputStream(messsageBytes);
> 		msg.setContent(InputStream.class, in);
>
> 		conduit.close(msg);
> 		return  mo.getResponseStream().toByteArray();
>
> 	}
> 	finally {
>
> 		try {
> 			if(in != null) {
> 				in.close();
> 			}
> 		} catch (Exception e) {
> 			logger.error("Error closing Stream: "+ e.getMessage());
> 		}
> 	}
>
>
> Thanks in advance



-- 
J. Daniel Kulp
Principal Engineer
IONA
P: 781-902-8727    C: 508-380-7194
daniel.kulp@iona.com
http://www.dankulp.com/blog