GithubHelp home page GithubHelp logo

How to handle command errors about cqrs HOT 5 CLOSED

nestjs avatar nestjs commented on April 26, 2024 7
How to handle command errors

from cqrs.

Comments (5)

sh3d2 avatar sh3d2 commented on April 26, 2024 1

Hi,

how about changing ICommandHandler.execute
from

    execute(command: T, resolve: (value?) => void);

to

    execute(command: T): Promise<any>;

that way we'd have full information about whether command handling was successful or not,
and handlers wouldnt have to deal with that ugly-looking-callback-style resolve 😄

from cqrs.

moltar avatar moltar commented on April 26, 2024 1

Using CommandResult would not make it possible to retry failed jobs though that are managed by some queue system. E.g. RabbitMQ. If a job failed, it'd go back to the queue and be retried again. This is a very useful pattern. But if all jobs always succeed, then this pattern is not possible.

from cqrs.

pawpartyka avatar pawpartyka commented on April 26, 2024

+1

from cqrs.

kamilmysliwiec avatar kamilmysliwiec commented on April 26, 2024

Hi,
The only way is to use resolve() method. Something like CommandResult sounds fine. 🙂

from cqrs.

mvanderkroon avatar mvanderkroon commented on April 26, 2024

@moltar I am looking exactly for the behaviour you mention: jobs managed by some queue system, such that in case the handler fails either caused by a (transient) exception, or the instance is shutdown, the job is retried automatically. Could you point me towards any resources/examples (anything really) on how to configure NestJS+Sagas in a manner to achieve exactly that?

from cqrs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.