我有一个SeedIndicatorInformationSQS-dev.fifo
队列(FiFo),它连接到一个SeedIndicatorInformationSQS-dev-d13dfe0
lambda。我想在SeedIndicatorInformationSQS-dev-d13dfe0
lambda内向EvaluationConfigSQS-dev
标准队列发送一条消息。但是没有消息正在发送/接收。而如果我尝试从非SQS连接的lambda(通过AppSync)发送邮件,则可以正常工作。
SeedIndicatorInformationSQS-dev-d13dfe0
lambda具有以下权限:
我已检查:
EvaluationConfigSQS-dev
标准队列,因为我已成功从另一个lambda(非SQS)向其发送了消息。这是SeedIndicatorInformationSQS-dev-d13dfe0
lambda试图分发内容的CloudWatch日志:成功发送到正确的URL,JSON解析为字符串,但没有任何响应。
这是CloudWatch日志:您可以看到。 SeedIndicatorInformationSQS-dev-d13dfe0
已成功从另一个lambda函数接收消息并对其进行处理,但没有其他消息发送。
SeedIndicatorInformationSQS-dev-d13dfe0
内未报告任何错误
但是,如果我尝试在非SQS lambda中发送它,则它可以工作。
这是classes-dev-eefa2af
lambda,它已成功发送到EvaluationConfigSQS-dev
(并且恰巧是触发SeedIndicatorInfromationSQS-dev.fifo
SQS的那个)。
以下是EvaluationConfigSQS-dev-6da8b90
(EvaluationConfigSQS-dev
标准队列触发的lambda)的权限
是否有机会向SeedIndicatorInformatioNSQS-dev.fifo
队列添加特殊权限?
这是要分发的JS(我正在使用中介模式,并且已成功分发,您可以在“ Dispatching CREATED_INSTITUTION_CLASS”上方的日志中看到它。我还设法打印了URL并验证了它的实际作用对应的那个。
export async function institutionClassCreatedEventHandler(
evt: InstitutionClassCreatedEvent
) {
const json = JSON.stringify({
...evt,
type: "CLASS_CREATED",
});
sqsDispatchMessage(
"InstitutionClassCreatedEvent",
evt.tenantId + evt.subject.id,
json,
Config.SQS.evaluationConfigSQS.url,
false
);
}
这是sqsDispatchMessage函数。如您所见,有一个catch块会在出现错误时将我打印出来(并且有效)。但到目前为止,尚未记录任何错误。
export async function sqsDispatchMessage(
eventName: string,
uniqueId: string,
jsonObjStringifiedToSend: string,
sqsURL: string,
isFifoQueue: boolean = true
) {
try {
await sqs
.sendMessage({
MessageAttributes: {
EventName: {
DataType: "String",
StringValue: eventName,
},
},
...(isFifoQueue && { MessageGroupId: eventName }),
MessageBody: jsonObjStringifiedToSend,
QueueUrl: sqsURL,
...(isFifoQueue && { MessageDeduplicationId: uniqueId }),
})
.promise();
} catch (e) {
console.error(`Error While Sending the ${eventName}`);
console.error(e.message);
console.log(jsonObjStringifiedToSend);
}
}
有什么想法吗?可能吗
答案 0 :(得分:1)
问题出在我的调度员中
以前是这样的:
export async function dispatchOfEvents({
type,
evtArgs,
}: MediatorEvents): Promise<void> {
logTime(type);
(events as any)[type].forEach((evt: Function) => {
evt(evtArgs);
});
}
我将其更改为:
export async function dispatchOfEvents({
type,
evtArgs,
}: MediatorEvents): Promise<void> {
logTime(type);
const evts: Promise<any>[] = [];
for (const evt of (events as any)[type]) {
evts.push(evt(evtArgs));
}
await Promise.all(evts);
}