Skip to content

Sticky handlers in modular monolith re-execute multiple times with global partitioning enabled #2303

@lyall-sc

Description

@lyall-sc

Describe the bug
As per title. I've attached the describe output, logging output (with comments) and I've attempted to summarize my relevant Wolverine configuration here:

o.Policies.AutoApplyTransactions();
o.Policies.UseDurableLocalQueues();
o.Policies.UseDurableInboxOnAllListeners();
o.Policies.UseDurableOutboxOnAllSendingEndpoints();
o.Policies.PropagateGroupIdToPartitionKey();

o.MessagePartitioning.UseInferredMessageGrouping()
    .ByPropertyNamed("Id")
    .GlobalPartitioned(c =>
    {
        var topology = c.UseShardedKafkaTopics(GlobalMessageQueueName, 1);

        foreach (var messageType in GetAllMessageTypes(routeConfiguration))
            topology.Message(messageType);
  });

o.UseKafka(server)
    .ConfigureConsumers(c =>
    {
        c.GroupId = applicationName;
    });

// for each Kafka listening topic
o.ListenToKafkaTopic(topic.Configuration.Name)
    .EnableNativeDeadLetterQueue();

// for each Kafka publisher topic
// each 'Route' contains just a message type for Kafka publishing plus any local handlers to which it should also be routed
foreach (var route in topic.Routes)
{
	o.Publish(c =>
	{
		_ = c.Message(route.MessageType)
			.ToKafkaTopic(topic.Configuration.Name);
	});

	if (route.LocalHandlerTypes != null && route.LocalHandlerTypes.Length > 0)
	{
		foreach (var handlerType in route.LocalHandlerTypes)
		{
			o.Publish(c =>
				c.Message(route.MessageType)
					.ToLocalQueue(handlerType.Namespace!)
					.AddStickyHandler(handlerType)
			);
		}
	}
}

To Reproduce
I don't have an isolated repro app but we test using messages published from an integration test to our local Kafka.

Expected behavior
No repeat execution of handlers.

describe.txt

logs.txt

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