You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by marcin80 <mt...@gmail.com> on 2010/01/23 12:01:10 UTC

camel and to many threds?

Hi,

I'm using Camel with ServiceMix4 (Fuse ESB) and I have problem with timer
component.
>From time to time my timer's thread stops. A thread dump is following:

 Name: timer:foo?period=5000
State: WAITING on
org.apache.camel.util.concurrent.CountingLatch$Sync@1b61ebd
Total blocked: 1  Total waited: 9 206

Stack trace: 
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
org.apache.camel.util.concurrent.CountingLatch.await(CountingLatch.java:93)
org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:175)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:90)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:69)
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:55)
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:98)
org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)
java.util.TimerThread.mainLoop(Timer.java:512)
java.util.TimerThread.run(Timer.java:462)

Where is the problem? Maybe too many threads is created?

Cheers,
Marcin
-- 
View this message in context: http://old.nabble.com/camel-and-to-many-threds--tp27285126p27285126.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel and to many threds?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Does this happen a lot? Or was the deadlock a one time only?

Camel 2.0 has a overhauled routing engine which has removed the need
for that type of latch. Which means this kind of deadlock does not
occur on 2.x.

However I have not seen this deadlock in 1.x before since the lock in
the code should be lowered again, but I guess hit hit a corner case.



On Mon, Jan 25, 2010 at 10:46 AM, marcin80 <mt...@gmail.com> wrote:
>
> Hi,
>
> Thanks for your response. My route is as follows:
>
> public class CamelRoute extends RouteBuilder {
>
>        public void configure() throws Exception {
>
>                from("timer:foo?period=5000").
>                        setBody(
>                         constant("select dz.xx, dz.embargo from sections dz where dz.xx in
> (65025,80269,85648,86235,86236,86237,86240,94355,94970)")).
>                to("jdbc:dataSource").
>                        choice().
>                                when(header("CamelJdbcRowCount").isEqualTo(0)).
>                                when(body().isEqualTo(new ArrayList<Long>())).
>                                        setBody(constant("ResultSet is empty")).
>
> to("log:org.camel.test?level=DEBUG").
>                                otherwise().
>                                        splitter(body(), true).to("bean:processor?method=processMessage").
>                                                setBody(constant("delete from sections")).
>                                                to("jdbc:dataSource").
>                                                setBody(header("jdbc.updateCount").convertTo(String.class)).
>                                                to("log:org.camle.test?level=DEBUG");
>        }
>
> }
>
> Timer fires every 5 seconds, retrieve records from database, splits its, and
> for each record calls bean's method (processMessage). This method creates
> quartz's job for certains records (there was about 100 quartz's tasks where
> timer was stopped).
>
> Cheers,
> Marcin
>
>
> --
> View this message in context: http://old.nabble.com/camel-and-too-many-threads--tp27285126p27304185.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: camel and to many threds?

Posted by marcin80 <mt...@gmail.com>.
Hi,

Thanks for your response. My route is as follows:

public class CamelRoute extends RouteBuilder {

	public void configure() throws Exception {
		
		from("timer:foo?period=5000").
			setBody(
			 constant("select dz.xx, dz.embargo from sections dz where dz.xx in
(65025,80269,85648,86235,86236,86237,86240,94355,94970)")).
		to("jdbc:dataSource").
			choice().
				when(header("CamelJdbcRowCount").isEqualTo(0)).
				when(body().isEqualTo(new ArrayList<Long>())).
					setBody(constant("ResultSet is empty")).
                                       
to("log:org.camel.test?level=DEBUG").
				otherwise().
					splitter(body(), true).to("bean:processor?method=processMessage").
						setBody(constant("delete from sections")).
						to("jdbc:dataSource").
						setBody(header("jdbc.updateCount").convertTo(String.class)).
						to("log:org.camle.test?level=DEBUG");
	}
	
}

Timer fires every 5 seconds, retrieve records from database, splits its, and
for each record calls bean's method (processMessage). This method creates
quartz's job for certains records (there was about 100 quartz's tasks where
timer was stopped).

Cheers,
Marcin

 
-- 
View this message in context: http://old.nabble.com/camel-and-too-many-threads--tp27285126p27304185.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel and to many threds?

Posted by Stan Lewis <ga...@gmail.com>.
What does your full route do?  It looks like it's stopped somewhere
along your route.  Have you done a full thread dump to see how many
threads are in this state?  Have you seen any instances of
OutOfMemoryError in your logs?  This could be an indicator of a thread
creation failure, or some other problem.  How long does it take for
this problem to occur once you've deployed your route?

On Sat, Jan 23, 2010 at 6:01 AM, marcin80 <mt...@gmail.com> wrote:
>
> Hi,
>
> I'm using Camel with ServiceMix4 (Fuse ESB) and I have problem with timer
> component.
> From time to time my timer's thread stops. A thread dump is following:
>
>  Name: timer:foo?period=5000
> State: WAITING on
> org.apache.camel.util.concurrent.CountingLatch$Sync@1b61ebd
> Total blocked: 1  Total waited: 9 206
>
> Stack trace:
> sun.misc.Unsafe.park(Native Method)
> java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
> org.apache.camel.util.concurrent.CountingLatch.await(CountingLatch.java:93)
> org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:175)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:90)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:69)
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:55)
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
> org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:98)
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)
> java.util.TimerThread.mainLoop(Timer.java:512)
> java.util.TimerThread.run(Timer.java:462)
>
> Where is the problem? Maybe too many threads is created?
>
> Cheers,
> Marcin
> --
> View this message in context: http://old.nabble.com/camel-and-to-many-threds--tp27285126p27285126.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>

Re: camel and too many threads?

Posted by huntc <hu...@mac.com>.
Could it be this:

http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html
-- 
View this message in context: http://old.nabble.com/camel-and-too-many-threads--tp27285126p27289273.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel and to many threds?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

 From the stack trace , it looks like you are still using Camel 1.x.
It looks like the camel timer thread is blocked by CountingLatch.
So I doubt if the async processor thread has some kind of dead lock with 
other thread.
Maybe you can work around it by increasing the timer's period time.

Willem

marcin80 wrote:
> Hi,
> 
> I'm using Camel with ServiceMix4 (Fuse ESB) and I have problem with timer
> component.
>>>From time to time my timer's thread stops. A thread dump is following:
> 
>  Name: timer:foo?period=5000
> State: WAITING on
> org.apache.camel.util.concurrent.CountingLatch$Sync@1b61ebd
> Total blocked: 1  Total waited: 9 206
> 
> Stack trace: 
> sun.misc.Unsafe.park(Native Method)
> java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:905)
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1217)
> org.apache.camel.util.concurrent.CountingLatch.await(CountingLatch.java:93)
> org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:175)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:90)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:69)
> org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:55)
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:80)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:189)
> org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:133)
> org.apache.camel.processor.Pipeline.process(Pipeline.java:115)
> org.apache.camel.processor.Pipeline.process(Pipeline.java:89)
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:98)
> org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:49)
> java.util.TimerThread.mainLoop(Timer.java:512)
> java.util.TimerThread.run(Timer.java:462)
> 
> Where is the problem? Maybe too many threads is created?
> 
> Cheers,
> Marcin