UNPKG

rocketmq-client-nodejs

Version:
90 lines (89 loc) 4.59 kB
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ClientType } from '../../proto/apache/rocketmq/v2/definition_pb'; import { AckMessageRequest, ChangeInvisibleDurationRequest, ForwardMessageToDeadLetterQueueRequest, HeartbeatRequest, NotifyClientTerminationRequest, ReceiveMessageRequest } from '../../proto/apache/rocketmq/v2/service_pb'; import { MessageView } from '../message'; import { MessageQueue, TopicRouteData } from '../route'; import { RetryPolicy } from '../retry'; import { Consumer, ConsumerOptions } from './Consumer'; import { FilterExpression } from './FilterExpression'; import { PushSubscriptionSettings } from './PushSubscriptionSettings'; import { ConsumeService } from './ConsumeService'; import { MessageListener } from './MessageListener'; export interface PushConsumerOptions extends ConsumerOptions { subscriptions: Map<string, FilterExpression | string>; messageListener: MessageListener; maxCacheMessageCount?: number; maxCacheMessageSizeInBytes?: number; longPollingTimeout?: number; enableFifoConsumeAccelerator?: boolean; } export declare class PushConsumer extends Consumer { #private; constructor(options: PushConsumerOptions); startup(): Promise<void>; /** * Start assignment scanning. Can be overridden by subclasses. */ protected startAssignmentScanning(): void; shutdown(): Promise<void>; protected getSettings(): PushSubscriptionSettings; /** * Get the client type for push consumer. * * @return The client type identifier */ protected getClientType(): ClientType; protected wrapHeartbeatRequest(): HeartbeatRequest; protected wrapNotifyClientTerminationRequest(): NotifyClientTerminationRequest; protected onTopicRouteDataUpdate(_topic: string, _topicRouteData: TopicRouteData): void; protected createConsumeService(): ConsumeService; subscribe(topic: string, filterExpression: FilterExpression): Promise<void>; unsubscribe(topic: string): void; get requestTimeoutValue(): number; getPushConsumerSettings(): PushSubscriptionSettings; getConsumerGroup(): string; getConsumeService(): ConsumeService; getRetryPolicy(): RetryPolicy | undefined; getClientId(): string; getReceptionTimes(): number; getReceivedMessagesQuantity(): number; getConsumptionOkQuantity(): number; getConsumptionErrorQuantity(): number; incrementReceptionTimes(): void; incrementReceivedMessagesQuantity(count: number): void; incrementConsumptionOkQuantity(): void; incrementConsumptionErrorQuantity(): void; doStats(): void; wrapPushReceiveMessageRequest(batchSize: number, mq: MessageQueue, filterExpression: FilterExpression, longPollingTimeout: number, attemptId?: string): ReceiveMessageRequest; receiveMessage(request: ReceiveMessageRequest, mq: MessageQueue, awaitDuration: number): Promise<MessageView[]>; wrapAckMessageRequest(messageView: MessageView): AckMessageRequest; wrapChangeInvisibleDurationRequest(messageView: MessageView, invisibleDuration: number): ChangeInvisibleDurationRequest; wrapForwardMessageToDeadLetterQueueRequest(messageView: MessageView): ForwardMessageToDeadLetterQueueRequest; getQueueSize(): number; cacheMessageBytesThresholdPerQueue(): number; cacheMessageCountThresholdPerQueue(): number; /** * Create a virtual process queue for Lite consumer. * Lite consumers use a special message queue with queueId=-1 to receive messages. * This method creates the virtual queue and starts fetching messages immediately. * * @param topic - The bind topic name * @param filterExpression - The filter expression for message filtering */ protected createVirtualProcessQueueForLite(topic: string, filterExpression: FilterExpression): void; }