Proof that Outbox is set up correct

If have enabled Outbox

        endpointConfiguration.EnableOutbox();

and is using appropriate transaction handling in my MessageHandler

        var session = context.SynchronizedStorageSession.SqlPersistenceSession();
        var connection = (SqlConnection)session.Connection;
        var transaction = (SqlTransaction)session.Transaction;

        // .. business code using the transaction

so my Outbox patterns should work probably (I see the dispatched rows in the Outbox table)

But how do I proof that my business code is using the correct connection/transaction and that it works in a failing scenario?

Hi @Stig_Christensen

Thanks for reaching out. This is for me a classical scenario of how much do you want to replicate tests on your side that should be the responsibility of our end :wink: We have a number of acceptance and persistence tests across the board the test those scenarios to make sure the expected behavior is guaranteed across the board. Of course we are also just humans and make mistakes from time to time but I still wonder if it is worth the investment on your end?

Short answer to your actual question:

One way to test it is for example adding a behavior in the batched dispatch phase (IBatchDispatchContext) that throws an exception once. During that phase the outbox records are already written to the database and we are trying to dispatch the outgoing messages. When that fails the incoming message is retried, the outbox records are loaded and dispatched again. There are also other scenarios you need to cover but again this goes deep into testing our implementation.

What might be valuable to test is that if you haven’t enabled the outbox across the board if the downstream receivers can handle transport message duplicates. As an example it is possible that multiple outgoing messages in the outbox table are part of the same outbox transaction and the transport fails in the middle of dispatching multiple such messages, retries and then sends all of them again.

The outbox documentation page talks about some of these scenarios too.

Regards
Daniel

This is for me a classical scenario of how much do you want to replicate tests on your side that should be the responsibility of our end

Since Outbox also needs special setup in our code, I think it needs to be proofed/tested. I have no doubt that the frameworks works.

I will try with a IBatchDispatchContext. Thanks