@message-queue-toolkit/kafka
Version:
Kafka adapter for message-queue-toolkit
35 lines (34 loc) • 2.1 kB
TypeScript
import type { QueueConsumerDependencies } from '@message-queue-toolkit/core';
import { type ConsumeOptions, type ConsumerOptions } from '@platformatic/kafka';
import { AbstractKafkaService, type BaseKafkaOptions } from './AbstractKafkaService.ts';
import type { KafkaHandlerRouting } from './handler-container/KafkaHandlerRoutingBuilder.ts';
import type { KafkaConfig, KafkaDependencies, TopicConfig } from './types.ts';
export type KafkaConsumerDependencies = KafkaDependencies & Pick<QueueConsumerDependencies, 'transactionObservabilityManager'>;
export type KafkaConsumerOptions<TopicsConfig extends TopicConfig[], ExecutionContext> = BaseKafkaOptions & Omit<ConsumerOptions<string, object, string, string>, 'deserializers' | 'autocommit' | keyof KafkaConfig> & Omit<ConsumeOptions<string, object, string, string>, 'topics'> & {
handlers: KafkaHandlerRouting<TopicsConfig, ExecutionContext>;
};
export declare abstract class AbstractKafkaConsumer<TopicsConfig extends TopicConfig[], ExecutionContext> extends AbstractKafkaService<TopicsConfig, KafkaConsumerOptions<TopicsConfig, ExecutionContext>> {
private readonly consumer;
private consumerStream?;
private readonly transactionObservabilityManager;
private readonly handlerContainer;
private readonly executionContext;
constructor(dependencies: KafkaConsumerDependencies, options: KafkaConsumerOptions<TopicsConfig, ExecutionContext>, executionContext: ExecutionContext);
/**
* Returns true if all client's connections are currently connected and the client is connected to at least one broker.
*/
get isConnected(): boolean;
/**
* Returns `true` if the consumer is not closed, and it is currently an active member of a consumer group.
* This method will return `false` during consumer group rebalancing.
*/
get isActive(): boolean;
init(): Promise<void>;
close(): Promise<void>;
private consume;
private tryToConsume;
private commitMessage;
private handleResponseErrorOnCommit;
private buildTransactionName;
private getRequestContext;
}