LiteBus
CatalogIngress

Host Loop and Consumer Enablement

  • ID: ingress.host-loop
  • Name: Host loop and consumer enablement
  • Maturity: GA
  • Summary: Controls whether the ingress consumer runs as manifest background work and how it restarts after faults.

Purpose and Scope

Ingress modules register TransportInboxIngressConsumer through IModuleConfiguration.RegisterBackgroundService when the module builder leaves EnableIngressConsumer true (default). TransportInboxIngressHostOptions controls runtime behavior:

PropertyDefaultRole
EnabledtrueSkip the consumer loop when false
RetryPollInterval5 secondsDelay before restarting after transport faults

Module builders expose DisableIngressConsumer() to register handler services without starting the subscription loop (custom consume paths or tests). Kafka builder also exposes ConfigureHost(Action<TransportInboxIngressHostOptions>).

Lifecycle Flow

flowchart TD
  R[Module registration] --> M{Ingress consumer enabled?}
  M -- yes --> B[Manifest registers TransportInboxIngressConsumer]
  M -- no --> H[Handler only registration]
  B --> S[Host starts background service]
  S --> C[Consumer subscribe loop]
  C --> F{Fault in loop?}
  F -- yes --> D[Log EventId 3002]
  D --> P[Delay RetryPollInterval]
  P --> C
  F -- no --> C

Public Surface

APIRole
*InboxIngressModuleBuilder.DisableIngressConsumer()Register handler without subscription loop
TransportInboxIngressHostOptions.EnabledSkip consumer loop when false (default true)
TransportInboxIngressHostOptions.RetryPollIntervalDelay before restarting after transport faults (default 5 s)
AmqpInboxIngressModuleBuilder.HostOptionsAMQP host tuning
KafkaInboxIngressModuleBuilder.ConfigureHost(Action<TransportInboxIngressHostOptions>)Kafka host tuning
IModuleConfiguration.RegisterBackgroundService(Type)Registers TransportInboxIngressConsumer when consumer enabled

Packages

  • LiteBus.Inbox.Ingress
  • All LiteBus.Inbox.Ingress.* module builders

Requires

  • hosting.manifest-background-services (generic host orchestrator)
  • ingress.transport-consumer

Invariants

  • Background services start after startup tasks complete (host orchestrator ordering).
  • Disabling the consumer still registers TransportInboxIngressHandler for manual accept scenarios.
  • Ingress does not register IHostedService directly; it uses manifest indirection.
  • Retry behavior is infinite until cancellation, with delay controlled by RetryPollInterval.

Broker Parity

Broker adapterDisableIngressConsumer()Host options customization
AMQPyesHostOptions property
KafkayesConfigureHost(...) API
AWS SQSyesHostOptions property
Azure Service BusyesHostOptions property
InMemoryyesHostOptions property

All adapters register the same TransportInboxIngressConsumer type when enabled.

Non-Goals

  • Separate ingress scheduler or cron host.
  • Dynamic hot reload of destination names without rebuild.
  • Health probes for broker connectivity (application registers IDiagnosticCheck).

Observability

SignalWhen emitted
EventId 3002, Warning, IngressRestartingConsumer loop fault; restart scheduled after RetryPollInterval
Manifest BackgroundServicestypeof(TransportInboxIngressConsumer) when consumer enabled

No host-loop-specific metrics. Background services start after startup tasks complete (host orchestrator). Disabling the consumer (DisableIngressConsumer) removes the manifest entry but leaves handler services for manual accept.

Test Coverage

Covered

Test methodProject
DisableIngressConsumer_ShouldNotRegisterIngressHostedServiceLiteBus.Storage.IntegrationTests (PostgreSql/)
InboxIngressExtensions_ShouldRegisterIngressServicesLiteBus.Durable.IntegrationTests (Registration/)
UseInMemoryIngress_ShouldAcceptProcessAndDispatchCommandLiteBus.Durable.IntegrationTests (Ingress/InMemory/)

End-to-end tests assert TransportInboxIngressConsumer on the host manifest when the consumer is enabled (PublishThroughRabbitMq_ShouldAcceptProcessAndDispatchCommand, PublishThroughKafka_ShouldAcceptProcessAndDispatchCommand, PublishThroughServiceBus_ShouldAcceptProcessAndDispatchCommand, PublishThroughSqs_ShouldAcceptProcessAndDispatchCommand).

Untested

  • TransportInboxIngressHostOptions.RetryPollInterval restart after transport fault (EventId 3002 path).
  • TransportInboxIngressHostOptions.Enabled = false at registration time.
  • KafkaInboxIngressModuleBuilder.ConfigureHost host tuning.
  • Kafka ingress host start/stop without hanging under rapid broker recycle.
  • Explicit restart timing assertions for SQS and Service Bus adapters.

Out-of-Scope

  • Separate ingress scheduler or cron host.
  • Dynamic hot reload of destination names without rebuild.
  • Broker connectivity health probes (IDiagnosticCheck).

Deep Docs

On this page