hosted-service

Implement IHostedService patterns with paired dead-letter queue processing for Azure Service Bus.

4|1|Updated Mar 15, 2026
One-click install
npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill hosted-service
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hosted-service
Source: https://github.com/FaysilAlshareef/dotnet-ai-kit/tree/main/skills/microservice/processor/hosted-service
Command: npx skills add https://github.com/FaysilAlshareef/dotnet-ai-kit --skill hosted-service

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Implements reliable IHostedService patterns with a paired dead-letter queue processor for Azure Service Bus, ensuring robust lifecycle management and explicit message handling.

Core Features & Use Cases

  • IHostedService implementation that wires a primary ServiceBusSessionProcessor with a paired DLQ processor.
  • Explicit message completion (AutoCompleteMessages = false) with clear error handling and logging.
  • Typed ServiceBus client wrapper pattern for clean DI and testability.
  • Guidance for registration, configuration, and best practices to avoid common anti-patterns.
  • Use Case: building resilient microservices that process sessionized Service Bus messages with DLQ reprocessing.

Quick Start

Create a new listener implementing IHostedService with a paired DLQ processor and register it with the DI container.

Frequently Asked Questions about hosted-service

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement an IHostedService with a dead-letter queue processor for Azure Service Bus?

You can implement an IHostedService by wiring a primary ServiceBusSessionProcessor with a paired DLQ processor, setting AutoCompleteMessages to false, and registering the typed ServiceBus client wrapper via dependency injection for clean testability.

How does explicit message completion work in a ServiceBusSessionProcessor?

Explicit message completion requires setting AutoCompleteMessages to false, ensuring your IHostedService manually completes messages after successful processing and applies clear error handling and logging for DLQ scenarios instead of relying on automatic completion.

What is the best way to handle ordered message processing in .NET microservices with Azure Service Bus?

The best way is using a ServiceBusSessionProcessor within an IHostedService pattern, which enables ordered message handling for sessionized messages while pairing a DLQ processor to manage failed message reprocessing.

Can I use dependency injection to register a Service Bus listener in a .NET hosted service?

Yes, you can register the Service Bus listener by using a typed ServiceBus client wrapper pattern within your DI container, which provides clean configuration and testability for your IHostedService implementation.

Why does my Azure Service Bus hosted service fail to reprocess dead-letter messages?

Failing to reprocess dead-letter messages often happens when the IHostedService lacks a paired DLQ processor; wiring a dedicated DLQ processor alongside the primary ServiceBusSessionProcessor resolves this missing reprocessing capability.

Do I need a paired DLQ processor for sessionized Azure Service Bus messages?

Yes, a paired DLQ processor is required for building resilient microservices that process sessionized Service Bus messages, ensuring failed messages are explicitly captured and reprocessed instead of being lost.