Skip to content
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

Idempotency issue with iotPublish API in publishToIOT.js #13

Open
NullPointer4096 opened this issue Apr 22, 2023 · 0 comments
Open

Idempotency issue with iotPublish API in publishToIOT.js #13

NullPointer4096 opened this issue Apr 22, 2023 · 0 comments

Comments

@NullPointer4096
Copy link

NullPointer4096 commented Apr 22, 2023

Description:
In the AWS Lambda function provided in serverless-coffee/backends/6-publisher-service/code/publishToIOT.js , there is an idempotency problem related to the iotPublish API. The code segment publishes a message to the IoT topic using the AWS SDK's iotdata.publish() method. If a failure occurs after the call to iotdata.publish(), subsequent retries of the Lambda function might cause duplicate events to be published, leading to potential issues in downstream systems that are consuming these events.

Steps to reproduce:

  1. Set up the provided Lambda code segment with the necessary environment variables and IoT data endpoint.
  2. Trigger the Lambda function execution by providing a valid event object.
  3. Introduce a failure in the Lambda function execution after the call to iotdata.publish(). This can be simulated through breakpoints or by throwing an exception.
  4. Let the Lambda function automatically retry.

Expected behavior:
The iotdata.publish() call should be idempotent, meaning that if the Lambda function is retried, it should not create duplicate events in the IoT topic.

Actual behavior:
When the Lambda function is retried, it creates duplicate events in the IoT topic, causing potential issues in downstream systems that are consuming these events.

Suggested fix:
Add a unique identifier (e.g., UUID) to the event payload before publishing it to the IoT topic. Then, in the downstream systems that consume these events, implement a deduplication mechanism based on the unique identifier.

By implementing these checks, the Lambda function can ensure idempotent behavior in the face of transient failures and retries.

Thank you for your contribution to the github community and I appreciate your effort in going through this issue.

@NullPointer4096 NullPointer4096 changed the title Idempotency issue with putEvents API in OrderProcessorWaitingCompletion.js Idempotency issue with iotPublish API in publishToIOT.js Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant