Skip to content

Commit

Permalink
fix msg timestamp when publish
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Raduenz committed Oct 22, 2020
1 parent 978c81a commit 04bec7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions amqp/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion amqp/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
})
}
Expand Down

0 comments on commit 04bec7e

Please sign in to comment.