perf(cmpp): reduce inbound database round trips
This commit is contained in:
@@ -67,7 +67,19 @@ export class SendGatewaySubmitService {
|
||||
}
|
||||
|
||||
|
||||
async enqueueBatchTask(taskId: string) {
|
||||
async enqueueBatchTask(taskId: string, preparedMessage?: { messageRecordId: string; queuePriority?: string | null }) {
|
||||
if (preparedMessage) {
|
||||
// CMPP内部任务在当前请求内刚完成持久化且不暴露取消入口,可安全复用已知ID;
|
||||
// 普通批量任务仍走下方查询路径,以保留取消检查和多消息枚举语义。
|
||||
const queuePriority = normalizeQueuePriority(preparedMessage.queuePriority);
|
||||
await this.facade.getSendQueue().add('send-message', { messageRecordId: preparedMessage.messageRecordId }, {
|
||||
jobId: preparedMessage.messageRecordId,
|
||||
attempts: 3,
|
||||
priority: BULLMQ_PRIORITY[queuePriority],
|
||||
});
|
||||
await this.prisma.smsBatchTask.update({ where: { id: taskId }, data: { status: 'queued' } });
|
||||
return { taskId, enqueued: 1 };
|
||||
}
|
||||
const task = await this.prisma.smsBatchTask.findUnique({ where: { id: taskId } });
|
||||
if (!task) {
|
||||
throw new NotFoundException('SMS batch task not found');
|
||||
|
||||
Reference in New Issue
Block a user