You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/30 07:42:02 UTC

[PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

He-Pin opened a new pull request, #3275:
URL: https://github.com/apache/pekko/pull/3275

   ### Motivation
   
   Projections and events-by-slice queries need to keep per-persistence-id sequence numbers gap free, which means filtered events must still be stored in the journal. Pekko Persistence had no shared placeholder payload for this, so query/projection plugins (e.g. r2dbc, projections) had nothing to align on.
   
   ### Modification
   
   - Add the public `FilteredPayload` case object, serialized to a 0-byte representation by the new internal `FilteredPayloadSerializer` (manifest `"F"`, serializer id `34`).
   - Register the serializer, binding and identifier in persistence `reference.conf`.
   - Make typed `EventEnvelope.event`/`getEvent` raise a clearer error when the payload is absent because the event was *filtered* (vs. simply *not loaded*).
   
   **Serializer id:** `34` matches the upstream id and follows pekko's established convention of preserving upstream serializer ids (e.g. `ReplicatedEventSourcingSerializer = 40` matches akka). Verified free within pekko's documented `0-40` reserved range.
   
   **Intentional divergence from upstream:** the upstream `akka-persistence-typed` reference.conf change was a cosmetic HOCON reformat (dotted key → block form) and is skipped; `scripts/show-serializer.sh` does not exist in pekko and is skipped.
   
   **Improvement over upstream:** added an `EventEnvelopeSpec` directional test covering the `filtered` vs `not loaded` error behaviour, which upstream shipped without a test.
   
   ### Result
   
   Pekko Persistence has a standard placeholder for filtered journal events, flagged as `filtered` in the typed `EventEnvelope`, enabling query and projection plugins to represent gap-free sequence numbers.
   
   which is now Apache licensed
   
   ### Tests
   
   - `sbt "persistence/testOnly org.apache.pekko.persistence.serialization.FilteredPayloadSerializerSpec"` (1/1 passed)
   - `sbt "persistence-query/testOnly org.apache.pekko.persistence.query.typed.EventEnvelopeSpec"` (2/2 passed)
   - `sbt "persistence/mimaReportBinaryIssues" "persistence-query/mimaReportBinaryIssues"` (clean)
   
   ### References
   
   Ports [akka/akka-core@b179bb1](https://github.com/akka/akka-core/commit/b179bb15279962d657b9192f374a98123fabd7ee) (akka#31985), which is now Apache licensed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #3275:
URL: https://github.com/apache/pekko/pull/3275#discussion_r3503327794


##########
persistence/src/main/resources/reference.conf:
##########
@@ -233,14 +233,17 @@ pekko.actor {
     serializers {
         pekko-persistence-message = "org.apache.pekko.persistence.serialization.MessageSerializer"
         pekko-persistence-snapshot = "org.apache.pekko.persistence.serialization.SnapshotSerializer"
+        pekko-persistence-filtered = "org.apache.pekko.persistence.serialization.FilteredPayloadSerializer"
     }
     serialization-bindings {
         "org.apache.pekko.persistence.serialization.Message" = pekko-persistence-message
         "org.apache.pekko.persistence.serialization.Snapshot" = pekko-persistence-snapshot
+        "org.apache.pekko.persistence.FilteredPayload$" = pekko-persistence-filtered
     }
     serialization-identifiers {
         "org.apache.pekko.persistence.serialization.MessageSerializer" = 7
         "org.apache.pekko.persistence.serialization.SnapshotSerializer" = 8
+        "org.apache.pekko.persistence.serialization.FilteredPayloadSerializer" = 34

Review Comment:
   Yes — serializer id 34 matches the upstream Akka id, following pekko's established convention of preserving upstream serializer ids (e.g. `ReplicatedEventSourcingSerializer = 40` also matches akka). Keeping this aligned ensures wire compatibility for any plugin that already hard-codes id 34 for `FilteredPayload`. Noted in the PR body under "Serializer id: 34 matches the upstream id".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #3275:
URL: https://github.com/apache/pekko/pull/3275#discussion_r3503327034


##########
persistence-query/src/test/scala/org/apache/pekko/persistence/query/typed/EventEnvelopeSpec.scala:
##########
@@ -0,0 +1,53 @@
+/*

Review Comment:
   This file is not copied from Akka — it is a new directional test I wrote for this PR (as noted in the PR body under "Improvement over upstream: added an EventEnvelopeSpec directional test covering the filtered vs not loaded error behaviour, which upstream shipped without a test"). The Akka `EventEnvelopeSpec` tests metadata support (single/composite), while this one tests `filtered` vs `not loaded` error semantics. The standard Apache header is correct here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3275:
URL: https://github.com/apache/pekko/pull/3275#discussion_r3502396838


##########
persistence-query/src/test/scala/org/apache/pekko/persistence/query/typed/EventEnvelopeSpec.scala:
##########
@@ -0,0 +1,53 @@
+/*

Review Comment:
   if this is copied from akka, we will need the Lightbend copyright header and the special Apache header that mentions Akka (the most common source header in Pekko code)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #3275:
URL: https://github.com/apache/pekko/pull/3275


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] feat: add FilteredPayload placeholder for filtered journal events [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #3275:
URL: https://github.com/apache/pekko/pull/3275#discussion_r3498532145


##########
persistence/src/main/resources/reference.conf:
##########
@@ -233,14 +233,17 @@ pekko.actor {
     serializers {
         pekko-persistence-message = "org.apache.pekko.persistence.serialization.MessageSerializer"
         pekko-persistence-snapshot = "org.apache.pekko.persistence.serialization.SnapshotSerializer"
+        pekko-persistence-filtered = "org.apache.pekko.persistence.serialization.FilteredPayloadSerializer"
     }
     serialization-bindings {
         "org.apache.pekko.persistence.serialization.Message" = pekko-persistence-message
         "org.apache.pekko.persistence.serialization.Snapshot" = pekko-persistence-snapshot
+        "org.apache.pekko.persistence.FilteredPayload$" = pekko-persistence-filtered
     }
     serialization-identifiers {
         "org.apache.pekko.persistence.serialization.MessageSerializer" = 7
         "org.apache.pekko.persistence.serialization.SnapshotSerializer" = 8
+        "org.apache.pekko.persistence.serialization.FilteredPayloadSerializer" = 34

Review Comment:
   Should we keep this the same as akka?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org