-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.76.0: SNS -> publish to subscribed SQS queue, "Records" assumption leads to lost message, empty array. #134
Comments
For me it works if I specify it like this. (Using your example) serverless-offline-sns:
port: 9324
debug: true
subscriptions:
- topic:
topicName: ${self:provider.environment.INGRESS_EVENT_TOPIC_NAME}
rawMessageDelivery: 'true'
queue: http://localhost:9324/queue/my-events Note the quotes in Then the line of code that you changed in your PR is not even touched, because it will take this branch: serverless-offline-sns/src/sns-server.ts Lines 348 to 349 in 5a29200
|
I made a similar fix to yours @bitsofinfo, but preserving the event shape for This alone causes #143 for me. But instead of using the fix proposed by that same PR #143, I just disabled the With the That was quite a journey. Hope this helps some others. |
I also forked from a previous tag to get this working and am maintaining the code at https://github.com/ormu5/serverless-offline-sns. |
0.76.0: SNS -> publish to subscribed SQS queue, "Records" assumption leads to lost message, empty array. mj1618#134 Bump serverless version to v3
0.76.0: SNS -> publish to subscribed SQS queue, "Records" assumption leads to lost message, empty array. mj1618#134 Bump serverless version to v3 Co-authored-by: Jimmy Huang <[email protected]>
…ds" assumption leads to lost message, empty array. mj1618#134 There is no need to check ` if (sub["Attributes"]["RawMessageDelivery"] === "true") ` inside `publishSqs`, this `RawMessageDelivery` check-process is already handled by `publish`. The `event` object is what should be sent directly to an sqs endpoint. This also works with serverless-offline-sqs plugin.
Fix mj1618#134 0.76.0: SNS -> publish to subscribed SQS queue, "Records" a…
using 0.76.0
My code is sending a message to SNS like this:
I have an SQS queue (in serverless-offline-sqs) that is subscribed to the event topic the code is publishing to (which is properly setup and I see the queue existing in elasticmq)
When I startup the app, I see the queue being successfully subscribed to my serverless-offline-sns created topic as expected.
When the code runs to send the SNS message, it is never received.
Tracking things down in the code I see that
sns-server.publish()
gets called and for each subscription it creates a new SNS message that ends up looking like this which wraps the message above that I published via the boto client:serverless-offline-sns/src/sns-server.ts
Line 351 in 6f6cde4
The
sns-server.publish()
method then callssns-server.publishSqs()
. In particular this line erroneously assumes that thatevent
contains aRecords
property array... which it doesn't... then yields an empty array[]
ultimately resulting in my message being lost and never sent:serverless-offline-sns/src/sns-server.ts
Line 310 in 6f6cde4
Seems like the
sns-server.publishSqs()
event is expecting the passedevent
to be in the format of thehelpers.createSnsLambdaEvent()
structure instead?serverless-offline-sns/src/helpers.ts
Line 75 in 6f6cde4
Original issue comment:
#88 (comment)
The text was updated successfully, but these errors were encountered: