A.K.A.MAGARICH
A.K.A.MAGARICH

Reputation: 31

OutBox pattern in MassTransit

My understanding is that the implementation of the OutBox pattern in MassTransit should save events when published to the bus. I am trying to add Entity framework Outbox in two services with my DB.

c.AddEntityFrameworkOutbox<ProjectDbContext>(cfg =>
            {
                cfg.UsePostgres();
                cfg.UseBusOutbox();
            });

I need the OutBox pattern in case the bus is unavailable. https://masstransit.io/documentation/configuration/middleware/outbox in the MassTransit documentation OutBox is added together with saga. When disabling RabbitMq to emulate a bus crash, no records of unpublished events appear in the database. How can I add OutBox to MassTransit without saga?

I added extensions to the database context and called the AddEntityFrameworkOutBox method when configuring MassTransit.

Upvotes: 1

Views: 4054

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33457

The Transactional Outbox uses the underlying database to store messages. However, the actual storage is controlled by your application. Ensure that you are calling SaveChangesAsync on the DbContext after your database operations are completed and any messages have been produced.

The sample demonstrates this clearly, along with the accompanying video.

Upvotes: 2

Related Questions