Q.Aimad
Q.Aimad

Reputation: 73

Is there a way to enable outbox in MassTransit just for specific message types?

I have a use case were I want to add outbox feature in MassTransit in some of my messages but not all.

In other words when i'm publishing using IPublishEndpoint to a message "UploadImage" I want to use outbox so I need to also commit changes to database. But, when I'am publishing to lets say "ImageDeleted" I don't want to use outbox I want to publish to the receive endoint directly to the message broker

I have followed the documentation of Masstransit and configured outbox and it is working. Sadly i didn't find a way to implement what I want to do.

Do I neet to implement multiBus for this? is there no other way?

Upvotes: 2

Views: 949

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33467

If you are within a consumer, and you want to skip the outbox for a specific message, you can use the following internal method:

var skipContext = InternalOutboxExtensions.SkipOutbox(context);

await skipContext.Publish(new ImageDeleted(...));

If you aren't within a consumer, can you use IBus?

Upvotes: 5

Related Questions