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

Is it possible to use outbox without overwriting SaveChanges #164

Open
RomanOlegovich opened this issue Apr 28, 2022 · 2 comments
Open

Is it possible to use outbox without overwriting SaveChanges #164

RomanOlegovich opened this issue Apr 28, 2022 · 2 comments

Comments

@RomanOlegovich
Copy link

There are cron jobs, which are produce events. So I want to push event into outobox without using of DbContext (just to handle if queue doesn't work). Does Silverback help to me?)

@RomanOlegovich
Copy link
Author

  1. SetUp outbox DbContext and ProduceToOutBoxTable
  2. Call publisher.Push()
  3. What I should do to send events to outbox?

@BEagle1984
Copy link
Owner

Overriding the SaveChanges method is necessary only to automatically publish the domain events embedded in the models (aggregates) being saved. The outbox works independently of that and you just need to call a SaveChanges after you published the messages in order for them to be persisted.

await publisher.PublishAsync(message1);
await publisher.PublishAsync(message2);
await publisher.PublishAsync(message3);

await dbContext.SaveChangesAsync();

Using the outbox without the DbContext altogether is not possible. Currently, the only way to write to the database is through a DbContext. Again, this will change in Silverback 4. 😉

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