'Multiple Send filters with KafkaFactoryConfigurator

is it possible to configure Kafka Rider to use more than one SendFilter? When I'm looking to KafkaFactoryConfigurator it can register only one delegate to configure SendFilter.

What I want to do. First, I communicate with SpringBoot application over Kafka topics, and I need to send same headers name for i.e. MessageId. And I want to also send some Business context information with additional headers. I don't want to mix these two concerns in one filter. But I don't know how to setup two filters for Kafka Rider.

I also tried to setup filters on InMemmoryBus but it looks that these filters are not used together with Rider Send.

Is there a way how to do it?

I'm using MassTransit v8.

Thank you.


EDIT: My setup looks like this sample

     builder.Services.AddMassTransit(x =>
    {
        x.UsingInMemory((context, config)=> {
            //config.UseSendFilter(typeof(KBHeaderFilter<>), context);
        });
        x.AddRider(rider =>
        {
            rider.AddProducer<MessageV1>("to-poc-masstransit", (riderContext, producerConfig) =>
            {
                var schemaRegistryClient = riderContext.GetRequiredService<ISchemaRegistryClient>();
                var serializerConfig = new AvroSerializerConfig{...};
                producerConfig.SetValueSerializer(new AvroSerializer<MessageV1>(schemaRegistryClient, serializerConfig).AsSyncOverAsync());
            });
    
            rider.UsingKafka((context, k) =>
            {
                //k.UseSendFilter(typeof(TestScopedFilter<>), context);
                k.SetHeadersSerializer(new TestSerializer());
                k.Host("localhost:port");
            });
        });
    });

I want to find a single place where I can override sent headers. But it looks like that appropriate place is the place where serialization/deserialization is made. This place is not the same for standard brokers and riders and I will have to implement my own header serializer for Kafka rider and another for Artemis broker.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source