I made a Linux virtual machine that is running Kafka. 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.
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:
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.
Thank you for any help. :D
You may find my article helpful: I provided comprehensive instructions on how to consume from C# and explained a couple of subtle points.
If you have any questions, feel free to ask!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.