Skip to content

Event acknowledgement #2

@icebob

Description

@icebob
  • Start Date: 2019-09-04
  • Target Version: (0.14 / 0.15)
  • Reference Issues: (fill in existing related issues, if any)
  • Implementation PR: (leave this empty)

Summary

Implement acknowledgement for events.

Basic example

In caller side

await this.broker.emit("user.created", { user }, { ack: true });

In event handler side

// activation.service.js
module.exports = {
    name: "activation",

    events: {
        async "user.created"(ctx) {
            try {
            await this.activateUser(ctx.params.user);
            
            // Acknowledges the received event.
            ctx.ack();
            } catch(err) {
                // Negative acknowledges the received event.
                ctx.nack();
            }
        }
    }
};

Motivation

TODO

Detailed design

TODO

Drawbacks

TODO

Alternatives

TODO

Adoption strategy

TODO

Unresolved questions

  • What happens with broadcast messages. Sending to all services?
  • What happens if mixins register the same event listener, so the service has multiple handlers for the same event?
  • How the caller side can check the acknowledgement result that it was successful or not?
  • What happens, if one listener was successful and other was failed?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions