You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "s.marjanovic" <sl...@gmail.com> on 2015/05/28 18:27:28 UTC

How to react when there is a fixed period of inactivity (no traffic) in a route?

Hello,

I have the following situation in the bundle I'm currently building:

Route 1: from(entryTopic).to(targetQueue/bufferQueue)
This route sends the messages to targetQueue until a certain messageA comes
along. When that happens messages are routed either to targetQueue or to
bufferQueue depending on the type of messages. This is in effect until
messageB arrives and nullifies the effect of messageA and all the messages
are again routed straight to targetQueue.

Route 2: from(bufferQueue).to(targetQueue)
This route routes the messages from bufferQueue to targetQueue while
messageA rule is not in effect in Route1.

Route 3: from(quartz).to(targetQueue)
This route sends a sort of heartbeat message every minute to the
targetQueue, but also only when messageA rule is not in effect in Route 1.

Implementation so far is based on controlbus component, with which Route2
and Route3 are stopped when messageA arrives and started again when messageB
in Route1 arrives. Controlbus is invoked from Route1 once messageA or
messageB are recognized.

Now, the requirements have changed a bit, and Route3 should not send a
message if there was traffic within the past minute in Route 1 or Route 2.
If there is at least 1min of inactivity in both Route1 and Route2, it should
start sending the heartbeat every minute till the traffic in Route 1 or
Route2 resumes.

Is there a way to achieve this sort of reactivity from my Route3? Or perhaps
a different solution that would discard Route3 completely and focus on a
repeatable task that would monitor the first two routes and react when
needed?

All the routes are under the same camel context/route builder.

Camel version is 2.12.0.redhat-610379.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-react-when-there-is-a-fixed-period-of-inactivity-no-traffic-in-a-route-tp5767607.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to react when there is a fixed period of inactivity (no traffic) in a route?

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

I have logged a ticket to add a start timestamp then its easier for you to know
https://issues.apache.org/jira/browse/CAMEL-8824

On Tue, Jun 2, 2015 at 9:20 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Mon, Jun 1, 2015 at 12:26 PM, s.marjanovic
> <sl...@gmail.com> wrote:
>> Hi,
>>
>> I managed to get around the problem by using the statistics about the last
>> completed exchange and the elapsed time since last reset like this:
>>
>> Date lastCompletedExchangeTimestamp = (Date)
>> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
>>
>> .invoke(objectNameForRoute, "getLastExchangeCompletedTimestamp", null,
>> null);
>>
>> Date resetTimestamp = (Date)
>> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
>>                                                .invoke(objectNameForRoute,
>> "getResetTimestamp", null, null);
>>
>> One small question though, I'm assuming that getResetTimestamp will give me
>> the time that camel context was initialized or the time of the last reset of
>> statistics (which doesn't concern me for now since statistics aren't being
>> reset manually yet).
>
> When last reset.
>
>
>>
>> Am I right with my assumption? Is there anything better to replace
>> getResetTimestamp with? I'm interested in obtaining camel context
>> initialization timestamp here and haven't had luck finding an alternative to
>> getResetTimestamp.
>>
>
> You can get the uptime from the camel context.
>
>
>
>> Thanks
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/How-to-react-when-there-is-a-fixed-period-of-inactivity-no-traffic-in-a-route-tp5767607p5767731.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to react when there is a fixed period of inactivity (no traffic) in a route?

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jun 1, 2015 at 12:26 PM, s.marjanovic
<sl...@gmail.com> wrote:
> Hi,
>
> I managed to get around the problem by using the statistics about the last
> completed exchange and the elapsed time since last reset like this:
>
> Date lastCompletedExchangeTimestamp = (Date)
> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
>
> .invoke(objectNameForRoute, "getLastExchangeCompletedTimestamp", null,
> null);
>
> Date resetTimestamp = (Date)
> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
>                                                .invoke(objectNameForRoute,
> "getResetTimestamp", null, null);
>
> One small question though, I'm assuming that getResetTimestamp will give me
> the time that camel context was initialized or the time of the last reset of
> statistics (which doesn't concern me for now since statistics aren't being
> reset manually yet).

When last reset.


>
> Am I right with my assumption? Is there anything better to replace
> getResetTimestamp with? I'm interested in obtaining camel context
> initialization timestamp here and haven't had luck finding an alternative to
> getResetTimestamp.
>

You can get the uptime from the camel context.



> Thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-react-when-there-is-a-fixed-period-of-inactivity-no-traffic-in-a-route-tp5767607p5767731.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Re: How to react when there is a fixed period of inactivity (no traffic) in a route?

Posted by "s.marjanovic" <sl...@gmail.com>.
Hi,

I managed to get around the problem by using the statistics about the last
completed exchange and the elapsed time since last reset like this:

Date lastCompletedExchangeTimestamp = (Date)
camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
                                                            
.invoke(objectNameForRoute, "getLastExchangeCompletedTimestamp", null,
null);

Date resetTimestamp = (Date)
camelContext.getManagementStrategy().getManagementAgent().getMBeanServer()
                                               .invoke(objectNameForRoute,
"getResetTimestamp", null, null);

One small question though, I'm assuming that getResetTimestamp will give me
the time that camel context was initialized or the time of the last reset of
statistics (which doesn't concern me for now since statistics aren't being
reset manually yet).

Am I right with my assumption? Is there anything better to replace
getResetTimestamp with? I'm interested in obtaining camel context
initialization timestamp here and haven't had luck finding an alternative to
getResetTimestamp.

Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-react-when-there-is-a-fixed-period-of-inactivity-no-traffic-in-a-route-tp5767607p5767731.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to react when there is a fixed period of inactivity (no traffic) in a route?

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

You can get all sorts of statistics from JMX about the routes. Such as
timestamp from the last exchange.

On Thu, May 28, 2015 at 6:27 PM, s.marjanovic
<sl...@gmail.com> wrote:
> Hello,
>
> I have the following situation in the bundle I'm currently building:
>
> Route 1: from(entryTopic).to(targetQueue/bufferQueue)
> This route sends the messages to targetQueue until a certain messageA comes
> along. When that happens messages are routed either to targetQueue or to
> bufferQueue depending on the type of messages. This is in effect until
> messageB arrives and nullifies the effect of messageA and all the messages
> are again routed straight to targetQueue.
>
> Route 2: from(bufferQueue).to(targetQueue)
> This route routes the messages from bufferQueue to targetQueue while
> messageA rule is not in effect in Route1.
>
> Route 3: from(quartz).to(targetQueue)
> This route sends a sort of heartbeat message every minute to the
> targetQueue, but also only when messageA rule is not in effect in Route 1.
>
> Implementation so far is based on controlbus component, with which Route2
> and Route3 are stopped when messageA arrives and started again when messageB
> in Route1 arrives. Controlbus is invoked from Route1 once messageA or
> messageB are recognized.
>
> Now, the requirements have changed a bit, and Route3 should not send a
> message if there was traffic within the past minute in Route 1 or Route 2.
> If there is at least 1min of inactivity in both Route1 and Route2, it should
> start sending the heartbeat every minute till the traffic in Route 1 or
> Route2 resumes.
>
> Is there a way to achieve this sort of reactivity from my Route3? Or perhaps
> a different solution that would discard Route3 completely and focus on a
> repeatable task that would monitor the first two routes and react when
> needed?
>
> All the routes are under the same camel context/route builder.
>
> Camel version is 2.12.0.redhat-610379.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-react-when-there-is-a-fixed-period-of-inactivity-no-traffic-in-a-route-tp5767607.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/