From 04bec7e32d28dd6989e16e46e864968d1bd09cb0 Mon Sep 17 00:00:00 2001 From: Guilherme Raduenz Date: Wed, 21 Oct 2020 21:38:41 -0300 Subject: [PATCH] fix msg timestamp when publish --- amqp/consumer.go | 7 ++++--- amqp/producer.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/amqp/consumer.go b/amqp/consumer.go index c8b0396..398d53c 100644 --- a/amqp/consumer.go +++ b/amqp/consumer.go @@ -194,9 +194,10 @@ func (c *consumer) doDispatch(msg amqplib.Delivery, h *handler, retryCount int32 } log := logger.WithFields(logrus.Fields{ - "action": h.action, - "body": string(msg.Body), - "message_id": msg.MessageId, + "action": h.action, + "body": string(msg.Body), + "message_id": msg.MessageId, + "published_at": msg.Timestamp.String(), }) if err == nil { diff --git a/amqp/producer.go b/amqp/producer.go index 25ba8fd..9f500c5 100644 --- a/amqp/producer.go +++ b/amqp/producer.go @@ -95,7 +95,7 @@ func (p *producer) Publish(action string, data []byte) { Timestamp: now, Body: data, Headers: amqp.Table{ - "x-epoch-milli": now.Unix() / int64(time.Millisecond), + "x-epoch-milli": int64(now.UnixNano()/int64(time.Nanosecond)) / int64(time.Millisecond), }, }) }