[英].NET Web Core 5 API - How can I consume Kafka messages from my Linux server?
I made a Linux virtual machine that is running Kafka.我做了一个运行 Kafka 的 Linux 虚拟机。 I tested the producer and was able to consume it from my other computer.
我测试了生产者并且能够从我的另一台计算机上使用它。 Now I want to make a consumer that runs in my API that I'm working on.
现在我想创建一个在我正在处理的 API 中运行的消费者。
I'm trying to follow some tutorials, but they are confusing.我正在尝试遵循一些教程,但它们令人困惑。 I want to just run a consumer that will read the messages from the producer in my project.
我只想运行一个消费者,它将在我的项目中读取来自生产者的消息。 I downloaded the Confluent.Kafka package. Then I tried making a Services/ProcessOrdersService.cs file like so:
我下载了 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;
}
}
}
But I'm confusing on what to do after this?但是我对这之后该怎么办感到困惑? Can anyone point me in the right direction?
谁能指出我正确的方向? I've tried looking at some tutorials but I don't understand where things are supposed to go within my Web Core 5 API project.
我试过查看一些教程,但我不明白 go 在我的 Web Core 5 API 项目中应该在哪里。
Thank you for any help.感谢您的任何帮助。 :D
:D
You may find my article helpful: I provided comprehensive instructions on how to consume from C# and explained a couple of subtle points.您可能会发现我的文章很有帮助:我提供了关于如何使用 C# 的全面说明,并解释了几个细微的要点。
If you have any questions, feel free to ask!如果你有任何问题随时问!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.