最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Apache Camel ExchangeMessage timestamp field is empty - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

According 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.

发布评论

评论列表(0)

  1. 暂无评论