2025-04-16 18:26:25 +08:00
|
|
|
|
using Confluent.Kafka;
|
|
|
|
|
|
using System;
|
2025-04-09 14:33:20 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace JiShe.CollectBus.Kafka.Consumer
|
|
|
|
|
|
{
|
2025-04-15 15:49:22 +08:00
|
|
|
|
public interface IConsumerService
|
2025-04-09 14:33:20 +08:00
|
|
|
|
{
|
2025-04-15 15:49:22 +08:00
|
|
|
|
Task SubscribeAsync<TKey, TValue>(string topic, Func<TKey, TValue, Task<bool>> messageHandler, string? groupId=null) where TKey : notnull where TValue : class;
|
2025-04-15 11:15:22 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-04-15 15:49:22 +08:00
|
|
|
|
/// 订阅消息
|
2025-04-15 11:15:22 +08:00
|
|
|
|
/// </summary>
|
2025-04-15 15:49:22 +08:00
|
|
|
|
/// <typeparam name="TValue"></typeparam>
|
|
|
|
|
|
/// <param name="topic"></param>
|
|
|
|
|
|
/// <param name="messageHandler"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
Task SubscribeAsync<TValue>(string topic, Func<TValue, Task<bool>> messageHandler, string? groupId = null) where TValue : class;
|
|
|
|
|
|
|
|
|
|
|
|
Task SubscribeAsync<TKey, TValue>(string[] topics, Func<TKey, TValue, Task<bool>> messageHandler, string? groupId) where TKey : notnull where TValue : class;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 订阅消息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <typeparam name="TKey"></typeparam>
|
|
|
|
|
|
/// <typeparam name="TValue"></typeparam>
|
2025-04-15 11:15:22 +08:00
|
|
|
|
/// <param name="topics"></param>
|
|
|
|
|
|
/// <param name="messageHandler"></param>
|
|
|
|
|
|
/// <returns></returns>
|
2025-04-15 15:49:22 +08:00
|
|
|
|
Task SubscribeAsync<TValue>(string[] topics, Func<TValue, Task<bool>> messageHandler, string? groupId = null) where TValue : class;
|
|
|
|
|
|
|
2025-04-16 18:46:51 +08:00
|
|
|
|
Task SubscribeBatchAsync<TKey, TValue>(string[] topics, Func<IEnumerable<TValue>, Task<bool>> messageBatchHandler, string? groupId = null, int batchSize = 100, TimeSpan? batchTimeout = null) where TKey : notnull where TValue : class;
|
2025-04-16 18:26:25 +08:00
|
|
|
|
|
|
|
|
|
|
Task SubscribeBatchAsync<TKey, TValue>(string topic, Func<IEnumerable<TValue>, Task<bool>> messageBatchHandler, string? groupId = null, int batchSize = 100, TimeSpan? batchTimeout = null) where TKey : notnull where TValue : class;
|
|
|
|
|
|
|
2025-04-16 18:46:51 +08:00
|
|
|
|
Task SubscribeBatchAsync<TValue>(string topic, Func<IEnumerable<TValue>, Task<bool>> messageBatchHandler, string? groupId = null, int batchSize = 100, TimeSpan? batchTimeout = null, TimeSpan? consumeTimeout = null) where TValue : class;
|
|
|
|
|
|
|
|
|
|
|
|
Task SubscribeBatchAsync<TValue>(string[] topics, Func<IEnumerable<TValue>, Task<bool>> messageBatchHandler, string? groupId = null, int batchSize = 100, TimeSpan? batchTimeout = null, TimeSpan? consumeTimeout = null) where TValue : class;
|
2025-04-16 18:26:25 +08:00
|
|
|
|
|
2025-04-15 15:49:22 +08:00
|
|
|
|
void Unsubscribe<TKey, TValue>() where TKey : notnull where TValue : class;
|
2025-04-09 14:33:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|