IConfiguration vs IOptions NET
Synchronous and Asynchronous in .NET Core
Model Binding and Validation in ASP.NET Core
ControllerBase vs Controller in ASP.NET Core
ConfigureServices and Configure methods
IHostedService interface in .NET Core
ASP.NET Core request processing
| RabbitMQ in .NET Core | RabbitMQ vs Azure Service Bus | |
Azure Service Bus in .NET Core |
Azure Service Bus is a fully managed enterprise messaging service from Microsoft Azure. It enables reliable, asynchronous communication between distributed applications and microservices. It supports queues (point-to-point) and topics (publish/subscribe).
Below is a simple example of sending and receiving messages using Azure Service Bus in a .NET Core application.
// Install-Package Azure.Messaging.ServiceBus
using Azure.Messaging.ServiceBus;
using System;
using System.Threading.Tasks;
public class AzureServiceBusExample
{
private const string connectionString = "<Your-Service-Bus-Connection-String>";
private const string queueName = "demo-queue";
public static async Task Main()
{
// Create client
await using var client = new ServiceBusClient(connectionString);
// Sender
ServiceBusSender sender = client.CreateSender(queueName);
string messageBody = "Hello from Azure Service Bus!";
await sender.SendMessageAsync(new ServiceBusMessage(messageBody));
Console.WriteLine($"Sent: {messageBody}");
// Receiver
ServiceBusReceiver receiver = client.CreateReceiver(queueName);
ServiceBusReceivedMessage receivedMessage = await receiver.ReceiveMessageAsync();
Console.WriteLine($"Received: {receivedMessage.Body.ToString()}");
}
}
Azure Service Bus is a robust, cloud-native messaging service ideal for enterprise-grade distributed systems. It simplifies communication between microservices, supports advanced messaging patterns, and ensures reliability with minimal operational overhead.
| RabbitMQ in .NET Core | RabbitMQ vs Azure Service Bus | |