You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nomit babraa <h....@sheffield.ac.uk> on 2020/02/23 22:21:24 UTC
Stopping a Route when no more messages meet JMS selector
Hi
I was wondering if there is any way to do the following:
- A route starts up.
- It consumes certain messages from an AMQ queue using a selector.
- Once all current messages are consumed the route is
stopped/suspended (Control Bus, CamelContext.stop(),
THROTTLINGINFLIGHTROUTEPOLICY, etc)
I think I can use schedulers and throttling to almost achieve what I
want but I explicitly want the route to be stopped when all current
messages that are found by the selector are consumed.
I'm not sure how to get that metric and act upon it?
Many thanks for any advice...
n
Re: Stopping a Route when no more messages meet JMS selector
Posted by nomit babraa <h....@sheffield.ac.uk>.
Hi
Thanks for all the input.
Decided to use Jan's excellent suggestion, and non-IDE tested code
that worked straight off! :)
Many thanks indeed,
I'm slowly learning how powerful Camel is!
Cheers
On Mon, 24 Feb 2020 at 23:02, Jan Bednář <ma...@janbednar.eu> wrote:
>
> Hi,
> another idea can be pollEnrich. Content Enricher produces empty message,
> when timeout occures (in this case 1s). You can react on this by
> stopping route.
>
> from("timer:drain_messages?period=1")
> .pollEnrich("jms:queue?selector=whatever", 1000)
> .choice()
> .when(body().isNull())
> .to("controlbus:route?routeId=current&action=stop&async=true")
> .otherwise()
> .to("log:do_actual_processing");
>
> I have wrote this directly to email without my IDE, but I think this
> should work.
>
> Dne 24.2.2020 v 14:32 nomit babraa napsal(a):
> > Hi
> >
> > Looks interesting but can't see a way to set that property from any examples.
> >
> > I did find www reference to
> >
> > camel.springboot.duration-max-idle-seconds=
> >
> > but I was hoping for something I could set with JMS uri options or java DSL.
> >
> > Cheers
> >
> >
> >
> > On Mon, 24 Feb 2020 at 08:19, Alex Dettinger <al...@gmail.com> wrote:
> >> Not sure about the exact implementation, but I would investigate the camel
> >> code around MainSupport.durationIdle.
> >>
> >> On Sun, Feb 23, 2020 at 11:22 PM nomit babraa <h....@sheffield.ac.uk>
> >> wrote:
> >>
> >>> Hi
> >>>
> >>> I was wondering if there is any way to do the following:
> >>>
> >>> - A route starts up.
> >>> - It consumes certain messages from an AMQ queue using a selector.
> >>> - Once all current messages are consumed the route is
> >>> stopped/suspended (Control Bus, CamelContext.stop(),
> >>> THROTTLINGINFLIGHTROUTEPOLICY, etc)
> >>>
> >>> I think I can use schedulers and throttling to almost achieve what I
> >>> want but I explicitly want the route to be stopped when all current
> >>> messages that are found by the selector are consumed.
> >>>
> >>> I'm not sure how to get that metric and act upon it?
> >>>
> >>> Many thanks for any advice...
> >>>
> >>> n
> >>>
>
Re: Stopping a Route when no more messages meet JMS selector
Posted by Jan Bednář <ma...@janbednar.eu>.
Hi,
another idea can be pollEnrich. Content Enricher produces empty message,
when timeout occures (in this case 1s). You can react on this by
stopping route.
from("timer:drain_messages?period=1")
.pollEnrich("jms:queue?selector=whatever", 1000)
.choice()
.when(body().isNull())
.to("controlbus:route?routeId=current&action=stop&async=true")
.otherwise()
.to("log:do_actual_processing");
I have wrote this directly to email without my IDE, but I think this
should work.
Dne 24.2.2020 v 14:32 nomit babraa napsal(a):
> Hi
>
> Looks interesting but can't see a way to set that property from any examples.
>
> I did find www reference to
>
> camel.springboot.duration-max-idle-seconds=
>
> but I was hoping for something I could set with JMS uri options or java DSL.
>
> Cheers
>
>
>
> On Mon, 24 Feb 2020 at 08:19, Alex Dettinger <al...@gmail.com> wrote:
>> Not sure about the exact implementation, but I would investigate the camel
>> code around MainSupport.durationIdle.
>>
>> On Sun, Feb 23, 2020 at 11:22 PM nomit babraa <h....@sheffield.ac.uk>
>> wrote:
>>
>>> Hi
>>>
>>> I was wondering if there is any way to do the following:
>>>
>>> - A route starts up.
>>> - It consumes certain messages from an AMQ queue using a selector.
>>> - Once all current messages are consumed the route is
>>> stopped/suspended (Control Bus, CamelContext.stop(),
>>> THROTTLINGINFLIGHTROUTEPOLICY, etc)
>>>
>>> I think I can use schedulers and throttling to almost achieve what I
>>> want but I explicitly want the route to be stopped when all current
>>> messages that are found by the selector are consumed.
>>>
>>> I'm not sure how to get that metric and act upon it?
>>>
>>> Many thanks for any advice...
>>>
>>> n
>>>
Re: Stopping a Route when no more messages meet JMS selector
Posted by Darius Cooper <da...@gmail.com>.
What if you had a separate timer route that monitored some simple state and
suspended the original route?
E.g. every time the original route processes an exchange, it could update a
"Last Timestamp"
A separate timer route would check this timestamp.
If it is more than N seconds/minutes in the past, the first route would be
suspended.
Might be able to use Camel metrics, but that's probably overkill for this
use-case.
regards
Darius
On Mon, Feb 24, 2020 at 8:33 AM nomit babraa <h....@sheffield.ac.uk>
wrote:
> Hi
>
> Looks interesting but can't see a way to set that property from any
> examples.
>
> I did find www reference to
>
> camel.springboot.duration-max-idle-seconds=
>
> but I was hoping for something I could set with JMS uri options or java
> DSL.
>
> Cheers
>
>
>
> On Mon, 24 Feb 2020 at 08:19, Alex Dettinger <al...@gmail.com>
> wrote:
> >
> > Not sure about the exact implementation, but I would investigate the
> camel
> > code around MainSupport.durationIdle.
> >
> > On Sun, Feb 23, 2020 at 11:22 PM nomit babraa <h....@sheffield.ac.uk>
> > wrote:
> >
> > > Hi
> > >
> > > I was wondering if there is any way to do the following:
> > >
> > > - A route starts up.
> > > - It consumes certain messages from an AMQ queue using a selector.
> > > - Once all current messages are consumed the route is
> > > stopped/suspended (Control Bus, CamelContext.stop(),
> > > THROTTLINGINFLIGHTROUTEPOLICY, etc)
> > >
> > > I think I can use schedulers and throttling to almost achieve what I
> > > want but I explicitly want the route to be stopped when all current
> > > messages that are found by the selector are consumed.
> > >
> > > I'm not sure how to get that metric and act upon it?
> > >
> > > Many thanks for any advice...
> > >
> > > n
> > >
>
Re: Stopping a Route when no more messages meet JMS selector
Posted by nomit babraa <h....@sheffield.ac.uk>.
Hi
Looks interesting but can't see a way to set that property from any examples.
I did find www reference to
camel.springboot.duration-max-idle-seconds=
but I was hoping for something I could set with JMS uri options or java DSL.
Cheers
On Mon, 24 Feb 2020 at 08:19, Alex Dettinger <al...@gmail.com> wrote:
>
> Not sure about the exact implementation, but I would investigate the camel
> code around MainSupport.durationIdle.
>
> On Sun, Feb 23, 2020 at 11:22 PM nomit babraa <h....@sheffield.ac.uk>
> wrote:
>
> > Hi
> >
> > I was wondering if there is any way to do the following:
> >
> > - A route starts up.
> > - It consumes certain messages from an AMQ queue using a selector.
> > - Once all current messages are consumed the route is
> > stopped/suspended (Control Bus, CamelContext.stop(),
> > THROTTLINGINFLIGHTROUTEPOLICY, etc)
> >
> > I think I can use schedulers and throttling to almost achieve what I
> > want but I explicitly want the route to be stopped when all current
> > messages that are found by the selector are consumed.
> >
> > I'm not sure how to get that metric and act upon it?
> >
> > Many thanks for any advice...
> >
> > n
> >
Re: Stopping a Route when no more messages meet JMS selector
Posted by Alex Dettinger <al...@gmail.com>.
Not sure about the exact implementation, but I would investigate the camel
code around MainSupport.durationIdle.
On Sun, Feb 23, 2020 at 11:22 PM nomit babraa <h....@sheffield.ac.uk>
wrote:
> Hi
>
> I was wondering if there is any way to do the following:
>
> - A route starts up.
> - It consumes certain messages from an AMQ queue using a selector.
> - Once all current messages are consumed the route is
> stopped/suspended (Control Bus, CamelContext.stop(),
> THROTTLINGINFLIGHTROUTEPOLICY, etc)
>
> I think I can use schedulers and throttling to almost achieve what I
> want but I explicitly want the route to be stopped when all current
> messages that are found by the selector are consumed.
>
> I'm not sure how to get that metric and act upon it?
>
> Many thanks for any advice...
>
> n
>