Skip to content

Event does not get tagged after updating to 1.5.51.1 #552

@Haukinger

Description

@Haukinger

Version Information
all current (1.5.51.1 / 1.5.52)

Describe the bug
When updating Akka.Persistence.Sql.Hosting from 1.5.51 to 1.5.51.1, some tests fail. One of them relies on a message getting tagged and showing up in a stream. It does before the update but not after.

To Reproduce

  1. send a SubscribeCommand to the SubscriptionActor
  2. that produces and persists a SubscribedEvent
  3. the event gets tagged with "Subscription"
  4. SubscriptionListActor maintains a stream looking for that tag and the event should show up there

Expected behavior
in 1.5.51 the event is in the stream

Actual behavior
in 1.5.51.1 it's not

Environment
Windows, VS 2022, Resharper's Nunit Runner, Sqlite

Additional context
the tagger is configured here:

.WithSqlPersistence( connectionString,
                     providerName,
                     useWriterUuidColumn: true,
                     journalBuilder: journalBuilder =>
                                     {
                                         journalBuilder.AddWriteEventAdapter<MessageTagger>( "status-tagger",
                                         [
                                             typeof(ISubscriptionEvent)
                                         ] );
                                     } )

the SubscriptionActor lives in a shard region

.WithShardRegion<SubscriptionActor>( "subscriptions",
                                     ( _, _, dependencyResolver ) => entityId => dependencyResolver.Props<SubscriptionActor>( entityId ),
                                     new MessageExtractor( 10 ),
                                     new()
                                     {
                                         RememberEntities = true,
                                         Role = "core",
                                         JournalOptions = shardingJournalOptions,
                                         SnapshotOptions = shardingSnapshotOptions,
                                         RememberEntitiesStore = RememberEntitiesStore.Eventsourced,
                                         StateStoreMode = StateStoreMode.DData,
                                     } )

this is the tagger

internal sealed class MessageTagger : IWriteEventAdapter
{
    public const string SUBSCRIPTION_TAG = "Subscription";

    #region IWriteEventAdapter
    public string Manifest(object evt) => string.Empty;

    public object ToJournal(object @event)
    { // <- breakpoint here is never hit in 1.5.51.1
        switch (@event)
        {
            case ISubscriptionEvent subscriptionEvent:
                return subscriptionEvent.HasStreamer() && subscriptionEvent.HasSubscriber() ? new Tagged( @event, new[] { SUBSCRIPTION_TAG } ) : @event;
            default:
                return @event;
        }
    }
    #endregion
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions