You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by saw <tr...@hotmail.com> on 2016/08/29 22:49:52 UTC

Exception when suspending splitter

I have the following very simple test route:


I'm am attempting to suspend this route while it's splitting a file. The
route attempts to suspend but after the graceful shutdown runs out the rest
of lines are still processed and a RejectedExecutionException exception is
thrown for each line.


What do i need to do to avoid these exceptions. How do i suspend the
splitter?



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-when-suspending-splitter-tp5786964.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception when suspending splitter

Posted by Quinn Stevenson <qu...@pronoia-solutions.com>.
I don’t know if split supports suspend/resume - I think it would have to be the underlying component (in this case the file component).  Also, I believe suspend/resume is for a route or a context - not an exchange.  I think the route is trying to complete the current exchange (i.e. the current file) before it goes down.  You could try using .stopOnException(), but I’m not certain if that would help in this case or not.

Regardless, I don’t think you’ll be able to resume the exchange that’s inflight - it would need to start over (i.e. re-process the file).

> On Aug 30, 2016, at 1:45 PM, Brad Johnson <br...@mediadriver.com> wrote:
> 
> I suspect it's the streaming that's creating the problem but I can't be
> sure without testing.  If you test it by removing the streaming does the
> route suspend/stop successfully?
> 
> The reason I suggested using the ThrottlingRoutePolicy is you should be
> able to set that maxInflightExchanges to 0 when you want.  But I certainly
> understand if you don't want to try that.
> 
> On Tue, Aug 30, 2016 at 12:44 PM, saw <tr...@hotmail.com> wrote:
> 
>> Ranx thank you for your suggestions but what i was looking for was some
>> insight into the original problem, not a workaround.
>> 
>> I would really just like to know if the splitter supports suspend/resume
>> and
>> if i'm doing something wrong in the route configuration that are causing
>> the
>> exceptions.
>> 
>> 
>> 
>> --
>> View this message in context: http://camel.465427.n5.nabble.
>> com/Exception-when-suspending-splitter-tp5786964p5787007.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>> 


Re: Exception when suspending splitter

Posted by Brad Johnson <br...@mediadriver.com>.
I suspect it's the streaming that's creating the problem but I can't be
sure without testing.  If you test it by removing the streaming does the
route suspend/stop successfully?

The reason I suggested using the ThrottlingRoutePolicy is you should be
able to set that maxInflightExchanges to 0 when you want.  But I certainly
understand if you don't want to try that.

On Tue, Aug 30, 2016 at 12:44 PM, saw <tr...@hotmail.com> wrote:

> Ranx thank you for your suggestions but what i was looking for was some
> insight into the original problem, not a workaround.
>
> I would really just like to know if the splitter supports suspend/resume
> and
> if i'm doing something wrong in the route configuration that are causing
> the
> exceptions.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Exception-when-suspending-splitter-tp5786964p5787007.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Exception when suspending splitter

Posted by saw <tr...@hotmail.com>.
Ranx thank you for your suggestions but what i was looking for was some
insight into the original problem, not a workaround.

I would really just like to know if the splitter supports suspend/resume and
if i'm doing something wrong in the route configuration that are causing the
exceptions.



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-when-suspending-splitter-tp5786964p5787007.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception when suspending splitter

Posted by Brad Johnson <br...@mediadriver.com>.
There are a couple of items I might suggest.  One is to use a
ThrottlingRoutePolicy with your throttler.  That can permit to write your
own control so you can turn it up or down when you need to.

http://camel.apache.org/route-throttling-example.html

Notice how it has a percent of maximum and resume max percent.  So you can
set upper and lower thresholds.  But if you wanted you could either write
your own or extend it and make it so you could set it.

Or his another example that sort of segregates what the
ThrottlingRoutePolicy does. http://camel.apache.org/routepolicy.html

Notice how the policy refs can be chained together.

<bean id="date" class="org.apache.camel.routepolicy.quartz.SimpleDate"/>

 <bean id="startPolicy"
class="org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy">
     <property name="routeStartDate" ref="date"/>
     <property name="routeStartRepeatCount" value="1"/>
     <property name="routeStartRepeatInterval" value="3000"/>
 </bean>

 <bean id="throttlePolicy"
class="org.apache.camel.impl.ThrottlingInflightRoutePolicy">
     <property name="maxInflightExchanges" value="10"/>
 </bean>

 <camelContext id="testRouteContext" xmlns="
http://camel.apache.org/schema/spring">
     <route id="testRoute" autoStartup="false" routePolicyRef="startPolicy,
throttlePolicy">
         <from uri="seda:foo?concurrentConsumers=20"/>
         <to uri="mock:result"/>
     </route>
 </camelContext>
</route>

On Tue, Aug 30, 2016 at 12:10 AM, saw <tr...@hotmail.com> wrote:

> The route is suspended from another thread by calling
>
>
> Our use case is such that we need this functionality. The file needs to be
> parsed at a controlled rate and processed only at certain times. So every
> once in a while parsing needs to be paused and resumed later.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.
> com/Exception-when-suspending-splitter-tp5786964p5786969.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Exception when suspending splitter

Posted by saw <tr...@hotmail.com>.
The route is suspended from another thread by calling 
 

Our use case is such that we need this functionality. The file needs to be
parsed at a controlled rate and processed only at certain times. So every
once in a while parsing needs to be paused and resumed later.



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-when-suspending-splitter-tp5786964p5786969.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception when suspending splitter

Posted by Ranx <br...@mediadriver.com>.
You may want to put this in instead of the static log message.  This will
show you what you are actually getting out of your splitter.

.log("${body")

How are you trying to suspend/stop the route?  I'm not positive and would
have to test it but you've specified streaming and that's going to have file
reader that it is using to parse.  Shutting down the route is going to
likely leave that open.  I can't be certain of that but that seems likely.

Why are you trying to suspend the file operation while it is streaming the
lines from the file?

Brad



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-when-suspending-splitter-tp5786964p5786965.html
Sent from the Camel - Users mailing list archive at Nabble.com.