0

I have a SeedIndicatorInformationSQS-dev.fifo queue (FiFo) that connects to a SeedIndicatorInformationSQS-dev-d13dfe0 lambda. I'd like to send a message within the SeedIndicatorInformationSQS-dev-d13dfe0 lambda to the EvaluationConfigSQS-dev standard queue. But no messages are being sent/received. Whereas if I try sending it from a non-SQS connected lambda (via AppSync) it works.

The SeedIndicatorInformationSQS-dev-d13dfe0 lambda has the following permissions: permissions lambda

I have checked:

  • That the lambda has the right access to send SQS messages (you can see it there).
  • That the EvaluationConfigSQS-devstandard queue is correctly configured as I've successfully sent messages to it from another lambda (non-SQS).
  • That the SQS URL is correct.
  • That no errors are shown in the console.
  • That async/await are correctly placed (I've tried both with and without them)

Here's the CloudWatch log for the SeedIndicatorInformationSQS-dev-d13dfe0lambda trying to dispatch the content: Successfully sent to the right URL, JSON parsed to string, but nothing.

enter image description here

Here's the CloudWatch Log: You can see. SeedIndicatorInformationSQS-dev-d13dfe0 successfully receives the message from another lambda function and processes it, but no further messages are sent.

enter image description here

No errors reported within SeedIndicatorInformationSQS-dev-d13dfe0

enter image description here

No logs within EvaluationConfigSQS-dev enter image description here

But, if I try to send it within a non-SQS lambda, it works. enter image description here

Received event: enter image description here

This is the classes-dev-eefa2af lambda that sends successfully to EvaluationConfigSQS-dev (and coincidentally is the one which triggers the SeedIndicatorInfromationSQS-dev.fifo SQS. enter image description here

Here are the permissions for EvaluationConfigSQS-dev-6da8b90 (lambda that the EvaluationConfigSQS-dev standard queue triggers)

enter image description here

By any chance, do I need to add special permissions to the SeedIndicatorInformatioNSQS-dev.fifo queue? enter image description here

Here's the JS that gets dispatched (I'm using a mediator pattern, and it's successfully getting dispatched, you can see it in the logs above "Dispatching CREATED_INSTITUTION_CLASS". I have also managed to print the URL and verified that it's actually the one that corresponds to it.

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 ); } 

Here's the sqsDispatchMessage function. As you can see, there's a catch block that will print me whenever there's an error (and it works). But so far, no error has been recorded.

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); } } 

Any ideas? Is it even possible?

3
  • BTW, there are no VPCs involved Commented Jun 12, 2020 at 15:39
  • 1
    Looking at the code snippets posted, I think this might be a case of async calls not being awaited correctly. Enable verbose logging for the AWS SDK to check if the SQS sendMessage API call is actually made and a response is received. Commented Jun 12, 2020 at 16:44
  • @Paradigm That was it! My problem was with the mediator pattern that I implemented. For event-based dispatches, I never awaited the implementations! All fixed!!! Thank you so much!! Commented Jun 12, 2020 at 19:15

1 Answer 1

1

The problem was in my dispatcher:

It used to be like this:

 export async function dispatchOfEvents({ type, evtArgs, }: MediatorEvents): Promise<void> { logTime(type); (events as any)[type].forEach((evt: Function) => { evt(evtArgs); }); } 

I changed it to:

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); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.