Re: Event / Exchange / Message timestamps
I also need the payload size of a message (in bytes) for each event and totals if possible Messages are mostly String, but can be any object basically (list, zip, mail, pdf, image). Is this possible? Or is there another way to get this kind of metric? The alternative is to offload it to, for example Elastic, but there maybe easier ways to get size stats. Raymond On Mon, Nov 20, 2023 at 11:23 PM ski n wrote: > Yes, I was suspecting something like that, but the Javadoc only says: > > "Timestamp for each event, when the event occurred. By default, the > timestamp is not included and this method returns 0." > > It does not say how and where it can be turned on. I first checked the > EventNotifierSupport class, but apparently it needs to be set on the > EventFactory: > > https://www.javadoc.io/static/org.apache.camel/camel-api/3.20.8/org/apache/camel/spi/EventFactory.html#setTimestampEnabled(boolean) > > Something like: > > context.getManagementStrategy().getEventFactory().setTimestampEnabled(true); > > Hope this will help someone. > > Raymond > >
Re: Event / Exchange / Message timestamps
Yes, I was suspecting something like that, but the Javadoc only says: "Timestamp for each event, when the event occurred. By default, the timestamp is not included and this method returns 0." It does not say how and where it can be turned on. I first checked the EventNotifierSupport class, but apparently it needs to be set on the EventFactory: https://www.javadoc.io/static/org.apache.camel/camel-api/3.20.8/org/apache/camel/spi/EventFactory.html#setTimestampEnabled(boolean) Something like: context.getManagementStrategy().getEventFactory().setTimestampEnabled(true); Hope this will help someone. Raymond
Re: Event / Exchange / Message timestamps
Hi No see the javadoc You need to turn on event timestamps On Mon, Nov 20, 2023 at 4:32 PM ski n wrote: > In Camel 3.20.8 I use the event notifier (as described here > https://dzone.com/articles/event-notifier-apache-camel). > > One of the things I try to get timestamps. These timestamps are available > on several levels: > > 1. Event level > 2. Exchange level > 3. Message level > > When I used the following the get the timestamps: > > CamelEvent.ExchangeEvent exchangeEvent = (CamelEvent.ExchangeEvent) event; > > // Get the message exchange from exchange event > Exchange exchange = exchangeEvent.getExchange(); > > System.out.println("Timestamp 1 " + event.getTimestamp()); > System.out.println("Timestamp 2 " + exchangeEvent.getTimestamp()); > System.out.println("Timestamp 3 " + exchange.getCreated()); > System.out.println("Timestamp 4 " + > exchange.getIn().getMessageTimestamp()); > > > Only timestamp 3 (exchange.getCreated()) gives a timestamp, but the others > are 0. For message timestamps this can be correct (as that depends on > ActiveMQ etc), but shouldn't the event always a timestamp? > > Raymond > -- Claus Ibsen - @davsclaus Camel in Action 2: https://www.manning.com/ibsen2