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

[Question] Best practices for handling events and error reporting in ASP.NET Core Web API #1275

Open
santhanuv opened this issue Jun 24, 2024 · 2 comments

Comments

@santhanuv
Copy link

Hi,

I'm using WorkflowCore in an ASP.NET Core Web API backend and calling publishEvent from a controller. Since the event is processed by the workflow as a background task, I'm unsure what response to return from the controller.

All our steps are short and should finish quickly, so I'm considering whether solutions like polling, long polling, or WebSockets are necessary.

If I send a generic 200 OK response after publishing the event and an error occurs during the execution of a step, how can I inform the front end about this issue? I'm using Angular on the front end and would like to handle this scenario effectively.

[HttpPost("publish-event")]
public async Task<IActionResult> PublishEvent([FromBody] EventModel model)
{
    await _workflowHost.PublishEvent(model.EventName, model.EventKey, model.EventData);
    return Ok();
}

Thanks!

@santhanuv santhanuv changed the title Best practices for handling events and error reporting in ASP.NET Core Web API [Question] Best practices for handling events and error reporting in ASP.NET Core Web API Jun 24, 2024
@slogsdon7
Copy link

I'd definitely return a 200 from that controller if the event published successfully. For dealing with step errors you can either query the status using the DbContext or use WFC's lifecycle events to handle errors more reactively.

@santhanuv
Copy link
Author

Thank you for your response, and I apologize for the long delay in getting back to you. Just to update you, we're currently sending a 200 OK status from the controller.

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

2 participants