event-routing

Route Service Bus events by subject to typed MediatR handlers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Routing Service Bus events by subject to the appropriate MediatR handlers inside a listener to avoid scattered manual routing logic and improve maintainability.

Core Features & Use Cases

  • Inline subject-based routing inside each listener (no separate router or event deserializer)
  • Typed event data dispatch via a generic HandleAsync<T> using IMediator
  • Structured logging and deterministic message completion (complete or abandon) for reliability in message processing

Quick Start

Configure a listener to route events by subject using a switch expression and handle them with typed MediatR handlers

Frequently Asked Questions about event-routing

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

FAQPage Schema
How do I route Service Bus events to MediatR handlers in C#?▼

Route Service Bus events by subject to typed MediatR handlers inside a listener using a switch expression to select the event type, then call a generic HandleAsync<T> to deserialize the payload and publish via IMediator. This avoids scattered manual routing logic and improves maintainability.

What is the best way to dispatch Service Bus messages by subject in .NET?▼

Dispatch Service Bus messages by subject using inline routing inside each listener. A switch expression selects the appropriate event type, eliminating the need for a separate router or event deserializer, while deterministic message completion ensures reliable processing.

How does a single listener handle multiple Service Bus event types?▼

A single listener handles multiple Service Bus event types by evaluating the subject with a switch expression, selecting the appropriate typed event, and calling a generic HandleAsync<T> method to deserialize and publish the payload via IMediator.

Can I use MediatR with Azure Service Bus listeners for event routing?▼

Yes, you can configure a Service Bus listener to route events by subject using a switch expression and handle them with typed MediatR handlers, enabling structured logging and deterministic message completion or abandonment based on the handler result.

Why use inline subject-based routing for Service Bus events instead of a separate router?▼

Inline subject-based routing inside each listener avoids scattered manual routing logic and removes the need for a separate router or event deserializer, improving maintainability while enforcing structured logging via LogContext and deterministic message completion.