camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gludington <gluding...@gmail.com>
Subject Shutting down camel and consumers
Date Fri, 28 Jul 2017 04:12:57 GMT
When I attempt to shutdown a camel context, the main thread stays open,
seemingly parked on the consumer.  For example, using a small variation on
the console sample (at end of message), which uses stream:in and stream:out,
I can start up a context, either using a SpringCamelContext or using
org.apache.camel.spring.Main.  However, when I stop the context using
camelContext.stop() in a separate thread, the context stops, but not
everything is released.  In the log, I will see all the messages, concluding
with:

23:52:14.711 [pool-2-thread-1] INFO
org.apache.camel.spring.SpringCamelContext - Apache Camel 2.19.0
(CamelContext: camel-1) uptime 42.866 seconds
23:52:14.713 [pool-2-thread-1] INFO
org.apache.camel.spring.SpringCamelContext - Apache Camel 2.19.0
(CamelContext: camel-1) is shutdown in 27.621 seconds

Stepping through the debugger I can see that StreamConsumer#doStop is
called, but a thread dump shows the camel-1 thread is still parked on
reading a line
	  at
org.apache.camel.component.stream.StreamConsumer.readFromStream(StreamConsumer.java:171)
	  at
org.apache.camel.component.stream.StreamConsumer.run(StreamConsumer.java:99)
	  at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	  at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

I saw similar behavior with a file consumer, as well.  Is there a proper way
to shut down all consumers as well when shutting down a camel context, so
that I can kill a specific spring context and release all resources without
shutting down the entire application?

The context in question:
<camelContext xmlns="http://camel.apache.org/schema/spring">
	<route>
    
    	<from uri="stream:in?promptMessage=Enter something: "/>
    	<choice>
		<when>
                <simple>${body} == 'cash'</simple>
                <log message="I HAVE CASH" loggingLevel="INFO"
logName="Test"/>
            </when>
            <when>
                <simple>${body} == 'credit'</simple>
				<log message="GIVE ME CREDIT" loggingLevel="INFO" logName="Test"/>
            </when>
            <otherwise>
                <log message="Excuse me, WHAT IS ${body}"
loggingLevel="INFO" logName="Test"/>
            </otherwise>
        </choice>

    
    <to uri="stream:out"/>
  	</route>
    </camelContext>

Thanks,
Greg



--
View this message in context: http://camel.465427.n5.nabble.com/Shutting-down-camel-and-consumers-tp5808223.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message