簡體   English   中英

.NET Web Core 5 API - 如何使用來自 Linux 服務器的 Kafka 消息?

[英].NET Web Core 5 API - How can I consume Kafka messages from my Linux server?

我做了一個運行 Kafka 的 Linux 虛擬機。 我測試了生產者並且能夠從我的另一台計算機上使用它。 現在我想創建一個在我正在處理的 API 中運行的消費者。

我正在嘗試遵循一些教程,但它們令人困惑。 我只想運行一個消費者,它將在我的項目中讀取來自生產者的消息。 我下載了 Confluent.Kafka package。然后我嘗試制作一個 Services/ProcessOrdersService.cs 文件,如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using System.Threading;
using POS.Models;
using Newtonsoft.Json;
using Confluent.Kafka;

namespace POS.Services
{
    public class ProcessOrdersService
    {

        private readonly ConsumerConfig consumerConfig;

        public ProcessOrdersService(ConsumerConfig consumerConfig)
        {
            this.consumerConfig = consumerConfig;
        }
    }
}

但是我對這之后該怎么辦感到困惑? 誰能指出我正確的方向? 我試過查看一些教程,但我不明白 go 在我的 Web Core 5 API 項目中應該在哪里。

感謝您的任何幫助。 :D

您可能會發現我的文章很有幫助:我提供了關於如何使用 C# 的全面說明,並解釋了幾個細微的要點。

如果你有任何問題隨時問!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM