I am trying to report latency metric for an Apache Camel Route by adding a bean at the end of the route and calculating the latency using the MESSAGE_TIMESTAMP field of the Exchange Message object.
The code is like this:
from("google-pubsub://...")
.process()
.bean("routeMetricsTimer","reportTimer");
In the RouteMetricsTimer bean, I tried to
long messageTimeStamp = exchange.getMessage().getMessageTimestamp();
long duration = System.currentTimeMillis() - messageTimeStamp;
//report the time taken to process the message
However I see that the MESSAGE_TIMESTAMP value is always 0.
Is there a setting to enable this attribute in the message?
I see this related answer suggests adding a timestamp property at the beginning of the route, but this question is about the MESSAGE_TIMESTAMP field.
I am trying to report latency metric for an Apache Camel Route by adding a bean at the end of the route and calculating the latency using the MESSAGE_TIMESTAMP field of the Exchange Message object.
The code is like this:
from("google-pubsub://...")
.process()
.bean("routeMetricsTimer","reportTimer");
In the RouteMetricsTimer bean, I tried to
long messageTimeStamp = exchange.getMessage().getMessageTimestamp();
long duration = System.currentTimeMillis() - messageTimeStamp;
//report the time taken to process the message
However I see that the MESSAGE_TIMESTAMP value is always 0.
Is there a setting to enable this attribute in the message?
I see this related answer suggests adding a timestamp property at the beginning of the route, but this question is about the MESSAGE_TIMESTAMP field.
https://stackoverflow/a/40522414/6352160
Share Improve this question asked Mar 28 at 1:07 ShankarShankar 2,8453 gold badges30 silver badges58 bronze badges1 Answer
Reset to default 1According to the doco: Message -Apache Camel
timestamp
: the timestamp the message originates from. Some systems like JMS, Kafka, AWS have a timestamp on the event/message that Camel receives. This method returns the timestamp if a timestamp exists.
It comes down to google-pubsub
protocol on whether it includes timestamp as part of its message. You might need to explicitly assign the timestamp prior to sending to the pubsub protocol.