java-slack-sdk
                                
                                 java-slack-sdk copied to clipboard
                                
                                    java-slack-sdk copied to clipboard
                            
                            
                            
                        Main thread in SlackApiLambdaHandler is completing before App's EventsDispatcher thread finishes in AWS Lambda. Am I missing something?
I have an App with a WorkflowStep that I pass into the constructor of a class that extends SlackApiLambdaHandler. I have tested the App locally so I know that app works. I have deployed the app to AWS Lambda but whenever the function is invoked the 'workstep execute' doesn't finish. I think this happens because the workflow execute step is queued and executed on a separate thread in EventsDispatcherImpl so the main thread finishes first.
I feel like I am missing something. Can someone please advice me on what to do next?
Thanks in advance!
Reproducible in:
The Slack SDK version
[INFO] +- com.slack.api:bolt:jar:1.24.0:compile
[INFO] |  +- com.slack.api:slack-api-model:jar:1.24.0:compile
[INFO] |  +- com.slack.api:slack-api-client:jar:1.24.0:compile
[INFO] |  \- com.slack.api:slack-app-backend:jar:1.24.0:compile
[INFO] +- com.slack.api:bolt-jetty:jar:1.24.0:compile
[INFO] |  +- com.slack.api:bolt-servlet:jar:1.24.0:compile
[INFO] +- com.slack.api:bolt-aws-lambda:jar:1.24.0:compile
Java Runtime version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
OS info
Steps to reproduce:
Expected result:
Actual result:
Requirements
Hi @Flyer4109, thanks for writing in.
The reason why the "workflow execute" event handling is executed asynchronously in a different thread is mentioned in the code comment as below:
As the workflows.stepCompleted is really slow (it always takes 3+ seconds), this middleware automatically runs the API call asynchronously. If you want to use your own mechanism to handle this, use your own middleware or add your primitive listener by App#worflowStepExecute() method. https://github.com/slackapi/java-slack-sdk/blob/v1.24.0/bolt/src/main/java/com/slack/api/bolt/middleware/builtin/WorkflowStep.java#L86-L100
Due to the above workflow platform API performance issue, running your app on container services such as ECS would be much easier. That being said, there is still a solution. If you would like to run the workflow step on AWS Lambda, a solution that I suggest would be:
- Set WorkflowStep#executeAutoAcknowledgement to false (default: true)
- Enqueue the execute event in SQS or whatever similar and then run the logic asynchronously (in a different AWS Lambda execution)
I hope this helps.
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.