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

Automatic commit transaction #191

Closed
yang-xiaodong opened this issue Aug 30, 2018 · 0 comments

Comments

@yang-xiaodong
Copy link
Member

commented Aug 30, 2018

In some cases, in order to streamline the code, we don't want to manually call the transaction.Commit() method. I hope that the CAP can help you commit the transaction. Then you can do it. You only need to pass the parameter when connection.BeginTransaction. autoCommit is true.

It should be noted that when using the transaction auto-commit function, you need to send a message after the completion of your business logic execution, which means that the _capBus.Publish line needs to be executed at last code of transaction.

using (var connection = new MySqlConnection(""))
{
    using (var transaction = connection.BeginTransaction(_capBus, autoCommit: true))
    {
        //your business code sample
        
        _capBus.Publish("sample.rabbitmq.mysql", DateTime.Now);                               
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.