Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

Azure Service Bus Explained | Why It Exists + Simple C# Demo

Автор: Luke Saunders (System Integration)

Загружено: 2025-10-19

Просмотров: 213

Описание:

In this video, we dive into Azure Service Bus — Microsoft’s enterprise-grade messaging service.

🔹 We’ll start by covering why Azure Service Bus exists and where it fits into modern cloud architecture.
🔹 Next, we’ll break down how it works, including queues, topics, and message handling.
🔹 Finally, we’ll build a simple C# application step by step to send and receive messages using Azure Service Bus.

Whether you’re new to messaging systems or want a quick refresher with a practical example, this tutorial will give you a solid foundation to get started.

📌 What you’ll learn:

🔹Why Service Bus is used in distributed systems
🔹Core concepts (queues, topics, subscriptions)
🔹How to implement a simple sender and receiver in C#

=== Timestamps ===
0:00 - Intro
0:41 - What does Azure Service Bus offer?
6:31 - Setting up an Azure Service Bus
13:41 - Building our C# App and testing the Queue

☕ SUPPORT THE CHANNEL
If you’re enjoying these videos and want to help me make more, consider buying me a coffee:
https://buymeacoffee.com/lukesaunders

#azureservicebus
#azuretutorials

C# code:
Receiver.cs
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
class Receiver
{
private const string connectionString = "Connection string here";
private const string queueName = "queue name here";
static async Task Main(string[] args)
{
Console.WriteLine($"Listening to queue: {queueName}");
await using var client = new ServiceBusClient(connectionString);

ServiceBusProcessor processor = client.CreateProcessor(queueName, new ServiceBusProcessorOptions
{
AutoCompleteMessages = true
});
processor.ProcessMessageAsync += MessageHandler;
processor.ProcessErrorAsync += ErrorHandler;
await processor.StartProcessingAsync();
Console.WriteLine("Press [Enter] to exit...");
Console.ReadLine();
await processor.StopProcessingAsync();
}
private static async Task MessageHandler(ProcessMessageEventArgs args)
{
string body = args.Message.Body.ToString();
string messageId = args.Message.MessageId;

Console.WriteLine($"Received message:");
Console.WriteLine($" MessageId: {messageId}");
Console.WriteLine($" Body: {body}");
Console.WriteLine($" -------------------------------------------------------------");
}
private static Task ErrorHandler(ProcessErrorEventArgs args)
{
Console.WriteLine($"Error: {args.Exception.Message}");
return Task.CompletedTask;
}
}
---------------------------------------------------------------------------------------------------------------------
Sender.cs
using System;
using System.IO;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;

class Sender
{
// Azure Service Bus connection details
private const string connectionString = "Connection string here";
private const string queueName = "queue name here";

static async Task Main(string[] args)
{
string directoryToWatch = @"C:\demos\servicebus\orderfiles"; // Change to your directory
string archiveDir = Path.Combine(directoryToWatch, "archive");
if (!Directory.Exists(archiveDir))
{
Directory.CreateDirectory(archiveDir);
}
Console.WriteLine($"Monitoring directory: {directoryToWatch}");

FileSystemWatcher watcher = new FileSystemWatcher(directoryToWatch, "*.xml");
watcher.Created += async (sender, e) ={angled bracket here} await OnNewFile(e.FullPath, archiveDir);
watcher.EnableRaisingEvents = true;

Console.WriteLine("Press [Enter] to exit...");
Console.ReadLine();
}

private static async Task OnNewFile(string filePath, string archiveDir)
{
try
{
Console.WriteLine($"New file detected: {filePath}");

await Task.Delay(1000);

string xmlContent = await File.ReadAllTextAsync(filePath);


await SendMessageToQueue(xmlContent);

string destFileName = Path.Combine(archiveDir, Path.GetFileName(filePath));
File.Move(filePath, destFileName, overwrite: true);

Console.WriteLine($"File {Path.GetFileName(filePath)} sent and archived.");
}
catch (Exception ex)
{
Console.WriteLine($"Error processing file {filePath}: {ex.Message}");
}
}

private static async Task SendMessageToQueue(string messageBody)
{
await using var client = new ServiceBusClient(connectionString);
ServiceBusSender sender = client.CreateSender(queueName);

ServiceBusMessage message = new ServiceBusMessage(messageBody);
await sender.SendMessageAsync(message);
}
}

Azure Service Bus Explained | Why It Exists + Simple C# Demo

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

Pushing a RabbitMQ Docker Container to Azure (Live Demo)

Pushing a RabbitMQ Docker Container to Azure (Live Demo)

Mastering Azure Event Grid | Topics, Subscriptions, Publishers & Handlers Explained (Live Demo)

Mastering Azure Event Grid | Topics, Subscriptions, Publishers & Handlers Explained (Live Demo)

What are File Transfer Protocols? - FTP, FTPS, SFTP and AS2 Explained

What are File Transfer Protocols? - FTP, FTPS, SFTP and AS2 Explained

Azure Data Factory Overview (ADF ETL)

Azure Data Factory Overview (ADF ETL)

Dream Factory: Предоставление доступа к базе данных Azure через API (демонстрация в реальном врем...

Dream Factory: Предоставление доступа к базе данных Azure через API (демонстрация в реальном врем...

Azure Mini-Series

Azure Mini-Series

3X-UI в 2026 году: Новые протоколы и возможности VLESS Reality/TLS

3X-UI в 2026 году: Новые протоколы и возможности VLESS Reality/TLS

Музыка для работы за компьютером | Фоновая музыка для концентрации и продуктивности

Музыка для работы за компьютером | Фоновая музыка для концентрации и продуктивности

Intro to Azure Service Bus - The Power Behind Microservices

Intro to Azure Service Bus - The Power Behind Microservices

Миллиарды на ветер: Су-57 - главный авиационный миф России

Миллиарды на ветер: Су-57 - главный авиационный миф России

Проектирование системы WHATSAPP: системы чат-сообщений для собеседований

Проектирование системы WHATSAPP: системы чат-сообщений для собеседований

Изучите Microsoft Active Directory (ADDS) за 30 минут

Изучите Microsoft Active Directory (ADDS) за 30 минут

⚡АСЛАНЯН: СЕЙЧАС! СРОЧНЫЙ разговор Трампа и Путина. ОТВЕТ диктатора УДИВИЛ ВСЕХ. Вот что ЗРЕЕТ

⚡АСЛАНЯН: СЕЙЧАС! СРОЧНЫЙ разговор Трампа и Путина. ОТВЕТ диктатора УДИВИЛ ВСЕХ. Вот что ЗРЕЕТ

AZURE SERVICE BUS QUEUE - Getting Started | Azure Series

AZURE SERVICE BUS QUEUE - Getting Started | Azure Series

СРОЧНО! ПОРТНИКОВ:

СРОЧНО! ПОРТНИКОВ: "Это эскалация". Лавров заявил об атаке на Путина, что с Трампом, РФ готовит удар

Building an API with Mulesoft

Building an API with Mulesoft

Azure AI Foundry Overview

Azure AI Foundry Overview

NoSQL Overview with Live Azure Cosmos Build

NoSQL Overview with Live Azure Cosmos Build

Transform Data into EDIFACT EDI Files with Altova MapForce | Step by Step Tutorial

Transform Data into EDIFACT EDI Files with Altova MapForce | Step by Step Tutorial

Transform a CSV into an X12 856 Using Altova MapForce (Part 1)

Transform a CSV into an X12 856 Using Altova MapForce (Part 1)

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]