Add original message timestamp to republished message headers (#3933)

Adds original message timestamp to republished message as
"Nats-Time-Stamp" header

 - [ ] Link to issue, e.g. `Resolves #NNN`
 - [ ] Documentation added (if applicable)
 - [x] Tests added
- [x] Branch rebased on top of current main (`git pull --rebase origin
main`)
- [x] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
 - [ ] Build is green in Travis CI
- [x] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)

Resolves #

### Changes proposed in this pull request:

- Add original message timestamp to republished message as header
"Nats-Time-Stamp"
 -
 -
This commit is contained in:
Derek Collison
2023-04-02 04:05:53 -07:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@@ -5651,6 +5651,12 @@ func TestJetStreamClusterStreamRepublish(t *testing.T) {
seq, err := strconv.Atoi(m.Header.Get(JSSequence))
require_NoError(t, err)
require_True(t, seq == i)
// Make sure timestamp is correct
ts, err := time.Parse(time.RFC3339Nano, m.Header.Get(JSTimeStamp))
require_NoError(t, err)
origMsg, err := js.GetMsg("RP", uint64(seq))
require_NoError(t, err)
require_True(t, ts == origMsg.Time)
// Make sure last sequence matches last seq we received on this subject.
last, err := strconv.Atoi(m.Header.Get(JSLastSequence))
require_NoError(t, err)