LiteBus
Integrations

Kafka Transport

Production tier: GA (transport platform and dispatch). Kafka ingress is Beta; see v6 feature index.

LiteBus.Transport.Kafka wraps Confluent.Kafka for publish and consume. Inbox and outbox adapters compose it independently; installing Kafka transport does not pull AMQP or AWS SDKs.

Packages to Install

PackageRole
LiteBus.Transport.KafkaITransportPublisher, KafkaConsumer, connection options
LiteBus.Inbox.Dispatch.KafkaOutbound command dispatch from inbox processor
LiteBus.Outbox.Dispatch.KafkaOutbound event publish from outbox processor
LiteBus.Inbox.Ingress.KafkaBroker intake into IInbox.AcceptAsync

Add inbox/outbox core and storage packages as usual. See Dependency graph.

Registration

var kafkaOptions = new KafkaTransportOptions
{
    BootstrapServers = "localhost:9092",
    ConnectivityCheckTimeout = TimeSpan.FromSeconds(3)
};

builder.AddKafkaTransport(kafkaOptions);
builder.AddMessaging(_ => { });
builder.AddInbox(inbox =>
{
    inbox.Contracts.Register<ShipOrderCommand>("orders.commands.ship", 1);
    inbox.UsePostgreSqlStorage(pg => pg.UseConnectionString(connectionString));
    inbox.UseInProcessDispatch();

    inbox.UseKafkaDispatch(kafka => kafka.DefaultDestination = "orders.commands");

    inbox.UseKafkaIngress(ingress =>
    {
        ingress.UseOptions(new KafkaInboxIngressOptions
        {
            Destination = "orders.commands",
            RequeueOnFailure = true
        });
    });

    inbox.EnableInboxProcessor();
});

Options Reference

TypePropertyDefaultNotes
KafkaTransportOptionsBootstrapServersrequiredBroker list
ConsumerGroupIdlitebus-transportConsumer group for ingress
ConnectivityCheckTimeout5 sReadiness cluster-description request timeout
SeekFailureBackoffInitial250 msDelay before re-read after seek
SeekFailureBackoffMax30 sCap on seek backoff
SeekFailureBackoffMultiplier2.0Per-offset failure multiplier
KafkaInboxIngressOptionsRequeueOnFailuretrueSeek back on transient accept failure
Safety.MaxInFlightMessages32Provider-neutral LiteBus handler cap

LiteBus does not expose a Kafka PrefetchCount setting. The Confluent.Kafka .NET consume loop returns records one at a time from the client's background fetch queue. Kafka fetch tuning remains in KafkaTransportOptions or the underlying client configuration when a supported option is added.

Guarantees and Non-Guarantees

GuaranteedNot guaranteed
At-least-once delivery when handlers ack after successful accept/dispatchExactly-once side effects
Offset committed only after TransportMessage.AcceptAsyncIn-session retry without seek on failure
Seek-on-failure rewinds to failed offset before next consumeOrdering across partitions

On transient ingress failure, ReturnToQueueAsync seeks the consumer to the failed offset. The offset is not committed until accept succeeds. Handlers must be idempotent.

Operations

SymptomCheckAction
Same message reprocessed repeatedlyConsumer lag, seek backoff logsFix root accept/dispatch failure; verify idempotency
Consumer stuck on one offsetRepeated seek at same partition/offsetInspect store availability; increase backoff cap if broker pressure
No ingressTopic name, group id, ACLsConfirm Destination topic exists; reset group if needed
transport.kafka.connectivity unhealthyBootstrap reachability, TLS/SASL, cluster ACLsFix broker access; tune ConnectivityCheckTimeout only when network latency requires it

Monitor consumer lag, seek retry rate, and inbox/outbox row counts. See Production runbook.

The root transport registers transport.kafka.connectivity. It uses Confluent's asynchronous cluster-description API with an explicit request timeout.

Tests

ScenarioLocation
Seek on ReturnToQueueAsyncLiteBus.Transport.UnitTests
Ingress transient failure redeliveryLiteBus.Durable.IntegrationTests (Ingress/Kafka/)
Ingress and dispatch round-tripLiteBus.Durable.IntegrationTests (Ingress/Kafka/, Dispatch/Inbox/Kafka/, Dispatch/Outbox/Kafka/)

On this page