Sreehari
Sreehari

Reputation: 3

Akka: currentEventsByPersistenceId always returns zero for 'eventEnvelope.timestamp'

I am experimenting with the currentEventsByPersistenceId query from akka-persistence-query to retrieve and process events stored in the messages table. However, I've encountered an issue where the EventEnvelope returned by this query has a timestamp field value of 0, instead of the insertion milliseconds since the epoch of 1970-01-01. Interestingly, the proper timestamp is available in the messages table, and I can retrieve it successfully if I switch to using the currentEventsByTag query instead of currentEventsByPersistenceId.

Here is the sample piece of code I tried

  1. eventEnvelope.timestamp always returns 0 in the following code.
val allEvents: Source[Any, NotUsed] = readJournal.currentPersistenceIds.flatMapConcat {
        persistenceId =>
          readJournal
            .currentEventsByPersistenceId(persistenceId, 1, Long.MaxValue)
            .map { eventEnvelope =>
              logger.info(s"timestamp = ${eventEnvelope.timestamp}, PID = ${eventEnvelope.persistenceId}, SEQ = ${eventEnvelope.sequenceNr}")
              // timestamp always returning zero. persistenceId and sequenceNr is printed correctly as in messages table
              eventEnvelope.event
            }
      }
  1. eventEnvelope.timestamp is printed correctly as per the messages table in the following code.
val tag = "specific-tag"
val allEventsByTag: Source[Any, NotUsed] = readJournal
        .currentEventsByTag(tag, NoOffset)
        .map { eventEnvelope =>
          logger.info(s"timestamp = ${eventEnvelope.timestamp}, PID = ${eventEnvelope.persistenceId}, SEQ = ${eventEnvelope.sequenceNr}")
          // timestamp is printed correctly as per the messages table
          eventEnvelope.event
        }

Am I missing something or is it a bug?

Upvotes: 0

Views: 67

Answers (0)

Related Questions