38 lines
1.4 KiB
C#
Raw Normal View History

2025-04-09 14:33:20 +08:00
using System;
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;
void Unsubscribe<TKey, TValue>() where TKey : notnull where TValue : class;
2025-04-09 14:33:20 +08:00
}
}